Exception: Brightpearl::RequestError
- Inherits:
-
StandardError
- Object
- StandardError
- Brightpearl::RequestError
- Defined in:
- lib/brightpearl/errors.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(msg, response: nil, status: nil) ⇒ RequestError
constructor
A new instance of RequestError.
Constructor Details
#initialize(msg, response: nil, status: nil) ⇒ RequestError
Returns a new instance of RequestError.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/brightpearl/errors.rb', line 4 def initialize(msg, response: nil, status: nil) if response["errors"] && response["errors"].size == 1 # If error is easily identifiable then set it as the Error message error = response["errors"][0]["message"] @code = response["errors"][0]["code"] super(error) else super(msg) end @response = response @status = status end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/brightpearl/errors.rb', line 3 def code @code end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/brightpearl/errors.rb', line 3 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/brightpearl/errors.rb', line 3 def status @status end |