Exception: Pobo::ApiError
Instance Attribute Summary collapse
-
#http_code ⇒ Object
readonly
Returns the value of attribute http_code.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, http_code: nil, response_body: nil) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(message, http_code: nil, response_body: nil) ⇒ ApiError
Returns a new instance of ApiError.
9 10 11 12 13 |
# File 'lib/pobo/errors.rb', line 9 def initialize(, http_code: nil, response_body: nil) @http_code = http_code @response_body = response_body super() end |
Instance Attribute Details
#http_code ⇒ Object (readonly)
Returns the value of attribute http_code.
7 8 9 |
# File 'lib/pobo/errors.rb', line 7 def http_code @http_code end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
7 8 9 |
# File 'lib/pobo/errors.rb', line 7 def response_body @response_body end |
Class Method Details
.from_response(http_code, body) ⇒ Object
19 20 21 22 |
# File 'lib/pobo/errors.rb', line 19 def self.from_response(http_code, body) = body.is_a?(Hash) ? (body["error"] || body["message"] || "API error") : "API error" new(, http_code: http_code, response_body: body) end |
.unauthorized ⇒ Object
15 16 17 |
# File 'lib/pobo/errors.rb', line 15 def self. new("Authorization token required", http_code: 401) end |