Exception: Railsmith::Failure
- Inherits:
-
StandardError
- Object
- StandardError
- Railsmith::Failure
- Defined in:
- lib/railsmith/failure.rb
Overview
Raised by BaseService.call! when the service returns a failure result. Carries the original Result so callers (or rescue_from handlers) can inspect the structured error without parsing a string message.
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #code ⇒ Object
- #error ⇒ Object
-
#initialize(result) ⇒ Failure
constructor
A new instance of Failure.
- #meta ⇒ Object
Constructor Details
#initialize(result) ⇒ Failure
Returns a new instance of Failure.
10 11 12 13 |
# File 'lib/railsmith/failure.rb', line 10 def initialize(result) @result = result super(result.error&. || "Service call failed") end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
8 9 10 |
# File 'lib/railsmith/failure.rb', line 8 def result @result end |
Instance Method Details
#code ⇒ Object
15 16 17 |
# File 'lib/railsmith/failure.rb', line 15 def code result.code end |
#error ⇒ Object
19 20 21 |
# File 'lib/railsmith/failure.rb', line 19 def error result.error end |
#meta ⇒ Object
23 24 25 |
# File 'lib/railsmith/failure.rb', line 23 def result. end |