Exception: Profitwell::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Profitwell::Error
- Defined in:
- lib/profitwell.rb,
lib/profitwell/exception.rb
Direct Known Subclasses
BadGateway, BadRequest, NotFound, RuntimeError, Unauthorized
Constant Summary collapse
- FAILED_HTTP_STATUSES =
Array(400..599)
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(response) ⇒ Error
Returns a new instance of Error.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/profitwell/exception.rb', line 7 def initialize(response) # body = JSON.parse(response.body) # @code = "#{response[:status]}" # @type = body['meta']['error_type'] # @message = body['meta']['error_message'] @code = response.code @error = FAILED_HTTP_STATUSES.include? response.code = response end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/profitwell/exception.rb', line 3 def code @code end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/profitwell/exception.rb', line 3 def error @error end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/profitwell/exception.rb', line 3 def end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/profitwell/exception.rb', line 3 def type @type end |