Exception: Tito::Errors::ApiError
- Defined in:
- lib/tito/errors.rb
Direct Known Subclasses
ForbiddenError, NotFoundError, RateLimitError, ServerError, UnauthorizedError, ValidationError
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(message = nil, status: nil, body: nil) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(message = nil, status: nil, body: nil) ⇒ ApiError
Returns a new instance of ApiError.
9 10 11 12 13 14 |
# File 'lib/tito/errors.rb', line 9 def initialize( = nil, status: nil, body: nil) @status = status @body = body @errors = body.is_a?(Hash) ? (body["errors"] || {}) : {} super( || (body.is_a?(Hash) && body["message"]) || "API error (#{status})") end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/tito/errors.rb', line 7 def body @body end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/tito/errors.rb', line 7 def errors @errors end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/tito/errors.rb', line 7 def status @status end |