Exception: Flowy::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Flowy::Error
- Defined in:
- lib/flowy/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code:, title: nil, detail: nil, meta: nil) ⇒ Error
constructor
A new instance of Error.
- #to_failure ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(code:, title: nil, detail: nil, meta: nil) ⇒ Error
Returns a new instance of Error.
19 20 21 22 23 24 25 |
# File 'lib/flowy/error.rb', line 19 def initialize(code:, title: nil, detail: nil, meta: nil) @code = code @title = title @detail = detail @meta = super((code, title, detail)) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/flowy/error.rb', line 4 def code @code end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
4 5 6 |
# File 'lib/flowy/error.rb', line 4 def detail @detail end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
4 5 6 |
# File 'lib/flowy/error.rb', line 4 def @meta end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/flowy/error.rb', line 4 def title @title end |
Class Method Details
.initialize_from_failure(failure:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/flowy/error.rb', line 6 def self.initialize_from_failure(failure:) unless failure.is_a?(Flowy::Failure) raise ArgumentError, "Flowy::Error requires a Flowy::Failure instance, got #{failure.class}" end new( code: failure.error_code, title: failure.error_title, detail: failure.error_description, meta: failure.error_data ) end |
Instance Method Details
#to_failure ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/flowy/error.rb', line 27 def to_failure Flowy::Failure.new( error_code: code, error_data: || {}, error_title: title, error_description: detail ) end |
#to_hash ⇒ Object
36 37 38 |
# File 'lib/flowy/error.rb', line 36 def to_hash to_failure.to_hash end |