Exception: OBarc::Utils::Exceptions::OBarcResponseError
- Inherits:
-
OBarcError
- Object
- StandardError
- OBarcError
- OBarc::Utils::Exceptions::OBarcResponseError
- Defined in:
- lib/obarc/utils/exceptions.rb
Instance Attribute Summary (collapse)
-
- (Object) error_code
readonly
Returns the value of attribute error_code.
-
- (Object) error_message
readonly
Returns the value of attribute error_message.
-
- (Object) http_code
readonly
Returns the value of attribute http_code.
Attributes inherited from OBarcError
Instance Method Summary (collapse)
-
- (OBarcResponseError) initialize(response)
constructor
A new instance of OBarcResponseError.
- - (Object) to_s
Constructor Details
- (OBarcResponseError) initialize(response)
Returns a new instance of OBarcResponseError
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/obarc/utils/exceptions.rb', line 55 def initialize(response) @http_code = response.code body = JSON.parse(response.body) @error_code, @error_message = if body.has_key?('error') [body['error']['code'], body['error']['message']] else [body['code'], body['message']] end @error_message = "UnknownError[#{@http_code}]." if @error_message.blank? super("Request Failed: #{@error_message}") end |
Instance Attribute Details
- (Object) error_code (readonly)
Returns the value of attribute error_code
53 54 55 |
# File 'lib/obarc/utils/exceptions.rb', line 53 def error_code @error_code end |
- (Object) error_message (readonly)
Returns the value of attribute error_message
53 54 55 |
# File 'lib/obarc/utils/exceptions.rb', line 53 def @error_message end |
- (Object) http_code (readonly)
Returns the value of attribute http_code
53 54 55 |
# File 'lib/obarc/utils/exceptions.rb', line 53 def http_code @http_code end |
Instance Method Details
- (Object) to_s
68 69 70 |
# File 'lib/obarc/utils/exceptions.rb', line 68 def to_s "#{@message}. error code: #{@error_code}, http status code: #{@http_code}" end |