Exception: Jirafe::Error::ResourceError
- Inherits:
-
JirafeError
- Object
- StandardError
- JirafeError
- Jirafe::Error::ResourceError
- Defined in:
- lib/jirafe/error.rb
Direct Known Subclasses
BadRequest, Forbidden, NotAllowed, ResourceNotFound, ServerError, Unauthorized, UnknownError
Instance Attribute Summary collapse
-
#http_body ⇒ Object
readonly
Returns the value of attribute http_body.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#json_body ⇒ Object
readonly
Returns the value of attribute json_body.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(response) ⇒ ResourceError
constructor
A new instance of ResourceError.
- #to_s ⇒ Object
Constructor Details
#initialize(response) ⇒ ResourceError
Returns a new instance of ResourceError.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/jirafe/error.rb', line 11 def initialize(response) parsed_error = JSON.parse(response.body) rescue response.body = parsed_error["error"]["message"] rescue parsed_error = parsed_error["error"]["data"].join(', ') rescue nil @message_data = JSON.parse(response.body)["error"]["data"] rescue nil @http_status = response.code @http_body = response.body @json_body = JSON.parse(response.body) rescue {} status_string = @http_status.nil? ? "" : "(Status #{@http_status}) " @message = "#{status_string}#{} #{}" end |
Instance Attribute Details
#http_body ⇒ Object (readonly)
Returns the value of attribute http_body.
8 9 10 |
# File 'lib/jirafe/error.rb', line 8 def http_body @http_body end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
7 8 9 |
# File 'lib/jirafe/error.rb', line 7 def http_status @http_status end |
#json_body ⇒ Object (readonly)
Returns the value of attribute json_body.
9 10 11 |
# File 'lib/jirafe/error.rb', line 9 def json_body @json_body end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/jirafe/error.rb', line 6 def @message end |
Instance Method Details
#to_s ⇒ Object
23 24 25 |
# File 'lib/jirafe/error.rb', line 23 def to_s @message end |