Class: NATS::Service::ErrorWrapper
- Inherits:
-
Object
- Object
- NATS::Service::ErrorWrapper
- Defined in:
- lib/nats/service/errors.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(error) ⇒ ErrorWrapper
constructor
A new instance of ErrorWrapper.
Constructor Details
#initialize(error) ⇒ ErrorWrapper
Returns a new instance of ErrorWrapper.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/nats/service/errors.rb', line 18 def initialize(error) case error when Exception @code = 500 @message = error. @data = "" when Hash @code = error[:code] @message = error[:description] @data = error[:data] when ErrorWrapper @code = error.code @message = error. @data = error.data else @code = 500 @message = error.to_s @data = "" end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
16 17 18 |
# File 'lib/nats/service/errors.rb', line 16 def code @code end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
16 17 18 |
# File 'lib/nats/service/errors.rb', line 16 def data @data end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
16 17 18 |
# File 'lib/nats/service/errors.rb', line 16 def @message end |
Instance Method Details
#description ⇒ Object
39 40 41 |
# File 'lib/nats/service/errors.rb', line 39 def description "#{code}:#{}" end |