Exception: Zesty::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Zesty::Error
- Defined in:
- lib/zesty/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
-
#response_headers ⇒ Object
readonly
Returns the value of attribute response_headers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, code, response_body, response_headers) ⇒ Error
constructor
A new instance of Error.
- #to_h ⇒ Object
Constructor Details
#initialize(message, code, response_body, response_headers) ⇒ Error
Returns a new instance of Error.
21 22 23 24 25 26 |
# File 'lib/zesty/error.rb', line 21 def initialize(, code, response_body, response_headers) super() @code = code @response_body = response_body @response_headers = response_headers end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/zesty/error.rb', line 4 def code @code end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
4 5 6 |
# File 'lib/zesty/error.rb', line 4 def response_body @response_body end |
#response_headers ⇒ Object (readonly)
Returns the value of attribute response_headers.
4 5 6 |
# File 'lib/zesty/error.rb', line 4 def response_headers @response_headers end |
Class Method Details
.from_response(data, response) ⇒ Object
7 8 9 10 |
# File 'lib/zesty/error.rb', line 7 def from_response(data, response) = parse_error(data) || response.to_s new(, response.code, response.to_s, response.headers.to_h) end |
Instance Method Details
#to_h ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/zesty/error.rb', line 28 def to_h { code: code, message: , response_body: response_body, response_headers: response_headers } end |