Exception: Buezli::Api::Client::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Buezli::Api::Client::Error
- Defined in:
- lib/buezli/api/client/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
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 17 18 19 20 21 22 23 24 |
# File 'lib/buezli/api/client/error.rb', line 7 def initialize(response) if response.is_a?(String) @details = {} @headers = {}.with_indifferent_access return super(response) end @status = response.code.to_i @response_body = response.body.to_s @headers = response.each_header.to_h.with_indifferent_access parsed = parse_json(response_body) @code = parsed&.dig("error", "code") @details = parsed&.dig("error", "details") || {} = parsed&.dig("error", "message") || response_body.presence || "#{response.code} #{response.}" super() end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/buezli/api/client/error.rb', line 5 def code @code end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
5 6 7 |
# File 'lib/buezli/api/client/error.rb', line 5 def details @details end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/buezli/api/client/error.rb', line 5 def headers @headers end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
5 6 7 |
# File 'lib/buezli/api/client/error.rb', line 5 def response_body @response_body end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/buezli/api/client/error.rb', line 5 def status @status end |