Exception: Uber::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Uber::Error
- Defined in:
- lib/uber/error.rb
Overview
Custom error class for rescuing from all Uber errors
Direct Known Subclasses
Defined Under Namespace
Modules: Code Classes: BadRequest, ClientError, ConfigurationError, Forbidden, InternalServerError, NotAcceptable, NotFound, RateLimited, RequestTimeout, ServerError, Unauthorized, UnprocessableEntity
Constant Summary collapse
- Codes =
rubocop:disable ConstantName
Code
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#rate_limit ⇒ Object
readonly
Returns the value of attribute rate_limit.
Class Method Summary collapse
- .errors ⇒ Hash
-
.from_response(response) ⇒ Uber::Error
Create a new error from an HTTP response.
Instance Method Summary collapse
-
#initialize(message = '', rate_limit = {}, code = nil) ⇒ Uber::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(message = '', rate_limit = {}, code = nil) ⇒ Uber::Error
Initializes a new Error object
73 74 75 76 77 |
# File 'lib/uber/error.rb', line 73 def initialize( = '', rate_limit = {}, code = nil) super() @rate_limit = Uber::RateLimit.new(rate_limit) @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/uber/error.rb', line 6 def code @code end |
#rate_limit ⇒ Object (readonly)
Returns the value of attribute rate_limit.
6 7 8 |
# File 'lib/uber/error.rb', line 6 def rate_limit @rate_limit end |
Class Method Details
.errors ⇒ Hash
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/uber/error.rb', line 32 def errors @errors ||= { 400 => Uber::Error::BadRequest, 401 => Uber::Error::Unauthorized, 403 => Uber::Error::Forbidden, 404 => Uber::Error::NotFound, 406 => Uber::Error::NotAcceptable, 422 => Uber::Error::UnprocessableEntity, 429 => Uber::Error::RateLimited, 500 => Uber::Error::InternalServerError } end |
.from_response(response) ⇒ Uber::Error
Create a new error from an HTTP response
26 27 28 29 |
# File 'lib/uber/error.rb', line 26 def from_response(response) , code = parse_error(response.body) new(, response.response_headers, code) end |