Exception: Feedlr::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Feedlr::Error
- Defined in:
- lib/feedlr/error.rb
Overview
Custom error class for rescuing from all Feedlr errors
Direct Known Subclasses
Defined Under Namespace
Classes: BadRequest, ClientError, Forbidden, InternalServerError, NotFound, RequestTimeout, ServerError, Unauthorized
Instance Attribute Summary collapse
-
#rate_limit ⇒ Object
readonly
Returns the value of attribute rate_limit.
Class Method Summary collapse
- .errors ⇒ Hash
-
.from_response(response) ⇒ Feedlr::Error
Create a new error from an HTTP response.
Instance Method Summary collapse
-
#initialize(message = '', rate_limit = {}) ⇒ Feedlr::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(message = '', rate_limit = {}) ⇒ Feedlr::Error
Initializes a new Error object
50 51 52 53 |
# File 'lib/feedlr/error.rb', line 50 def initialize( = '', rate_limit = {}) super() @rate_limit = Feedlr::RateLimit.new(rate_limit) end |
Instance Attribute Details
#rate_limit ⇒ Object (readonly)
Returns the value of attribute rate_limit.
6 7 8 |
# File 'lib/feedlr/error.rb', line 6 def rate_limit @rate_limit end |
Class Method Details
.errors ⇒ Hash
20 21 22 23 24 25 26 27 28 |
# File 'lib/feedlr/error.rb', line 20 def errors @errors ||= { 400 => Feedlr::Error::BadRequest, 401 => Feedlr::Error::Unauthorized, 403 => Feedlr::Error::Forbidden, 404 => Feedlr::Error::NotFound, 500 => Feedlr::Error::InternalServerError } end |
.from_response(response) ⇒ Feedlr::Error
Create a new error from an HTTP response
13 14 15 16 17 |
# File 'lib/feedlr/error.rb', line 13 def from_response(response) status_code = response.status.to_i = parse_error(status_code, response.body) new(, response.headers) end |