Exception: TurboBoost::Commands::CommandError
- Inherits:
-
StandardError
- Object
- StandardError
- TurboBoost::Commands::CommandError
- Defined in:
- lib/turbo_boost/commands/errors.rb
Direct Known Subclasses
AbortError, InvalidClassError, InvalidElementError, InvalidMethodError, InvalidTokenError, PerformError
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: :internal_server_error, cause: nil) ⇒ CommandError
constructor
A new instance of CommandError.
- #location ⇒ Object
Constructor Details
#initialize(*messages, command:, http_status: :internal_server_error, cause: nil) ⇒ CommandError
Returns a new instance of CommandError.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/turbo_boost/commands/errors.rb', line 8 def initialize(*, command:, http_status: :internal_server_error, 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.
20 21 22 |
# File 'lib/turbo_boost/commands/errors.rb', line 20 def cause @cause end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
20 21 22 |
# File 'lib/turbo_boost/commands/errors.rb', line 20 def command @command end |
#http_status_code ⇒ Object (readonly)
Returns the value of attribute http_status_code.
20 21 22 |
# File 'lib/turbo_boost/commands/errors.rb', line 20 def http_status_code @http_status_code end |
Instance Method Details
#location ⇒ Object
22 23 24 25 |
# File 'lib/turbo_boost/commands/errors.rb', line 22 def location line = (cause&.backtrace || []).first.to_s line.[](/[^\/]+\.rb:\d+/i) end |