Exception: TurboBoost::Commands::CommandError
- Inherits:
-
StandardError
- Object
- StandardError
- TurboBoost::Commands::CommandError
- Defined in:
- lib/turbo_boost/commands/errors.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cause ⇒ Object
readonly
Returns the value of attribute cause.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#http_status_code ⇒ Object
readonly
Returns the value of attribute http_status_code.
Instance Method Summary collapse
-
#initialize(*messages, command:, http_status:, cause: nil) ⇒ CommandError
constructor
A new instance of CommandError.
- #location ⇒ Object
Constructor Details
#initialize(*messages, command:, http_status:, cause: nil) ⇒ CommandError
Returns a new instance of CommandError.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/turbo_boost/commands/errors.rb', line 13 def initialize(*, command:, http_status:, cause: nil) @cause = cause @command = command @http_status_code = TurboBoost::Commands.http_status_code(http_status) .prepend "HTTP #{http_status_code} #{TurboBoost::Commands::HTTP_STATUS_CODES[http_status_code]}" << cause. if cause << location super(.uniq.select(&:present?).join("; ")) end |
Instance Attribute Details
#cause ⇒ Object (readonly)
Returns the value of attribute cause.
25 26 27 |
# File 'lib/turbo_boost/commands/errors.rb', line 25 def cause @cause end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
25 26 27 |
# File 'lib/turbo_boost/commands/errors.rb', line 25 def command @command end |
#http_status_code ⇒ Object (readonly)
Returns the value of attribute http_status_code.
25 26 27 |
# File 'lib/turbo_boost/commands/errors.rb', line 25 def http_status_code @http_status_code end |
Instance Method Details
#location ⇒ Object
27 28 29 30 |
# File 'lib/turbo_boost/commands/errors.rb', line 27 def location line = (cause&.backtrace || []).first.to_s line.[](/[^\/]+\.rb:\d+/i) end |