class Zesty::Error
Attributes
code[R]
response_body[R]
response_headers[R]
Public Class Methods
from_response(data, response)
click to toggle source
# File lib/zesty/error.rb, line 7 def from_response(data, response) message = parse_error(data) || response.to_s new(message, response.code, response.to_s, response.headers.to_h) end
new(message, code, response_body, response_headers)
click to toggle source
Calls superclass method
# File lib/zesty/error.rb, line 21 def initialize(message, code, response_body, response_headers) super(message) @code = code @response_body = response_body @response_headers = response_headers end
Private Class Methods
parse_error(data)
click to toggle source
# File lib/zesty/error.rb, line 14 def parse_error(data) if data.is_a?(Hash) data.dig(:message) || data.dig(:error) end end
Public Instance Methods
to_h()
click to toggle source
# File lib/zesty/error.rb, line 28 def to_h { code: code, message: message, response_body: response_body, response_headers: response_headers } end