Exception: EpoOps::Error
- Inherits:
-
StandardError
- Object
- StandardError
- EpoOps::Error
- Defined in:
- lib/epo_ops/error.rb
Constant Summary collapse
- ClientError =
Raised when EPO returns a 4xx HTTP status code
Class.new(self)
- BadRequest =
Raised when EPO returns the HTTP status code 400
Class.new(ClientError)
Class.new(ClientError)
- Forbidden =
Raised when EPO returns the HTTP status code 403
Class.new(ClientError)
- NotFound =
Raised when EPO returns the HTTP status code 404
Class.new(ClientError)
- NotAcceptable =
Raised when EPO returns the HTTP status code 406
Class.new(ClientError)
- UnprocessableEntity =
Raised when EPO returns the HTTP status code 422
Class.new(ClientError)
- TooManyRequests =
Raised when EPO returns the HTTP status code 429
Class.new(ClientError)
- ServerError =
Raised when EPO returns a 5xx HTTP status code
Class.new(self)
- InternalServerError =
Raised when EPO returns the HTTP status code 500
Class.new(ServerError)
- BadGateway =
Raised when EPO returns the HTTP status code 502
Class.new(ServerError)
Class.new(ServerError)
- GatewayTimeout =
Raised when EPO returns the HTTP status code 504
Class.new(ServerError)
- AccessTokenExpired =
AccessToken has expired
Class.new(ClientError)
- ERRORS =
{ 400 => EpoOps::Error::BadRequest, 401 => EpoOps::Error::Unauthorized, 403 => EpoOps::Error::Forbidden, 404 => EpoOps::Error::NotFound, 406 => EpoOps::Error::NotAcceptable, 422 => EpoOps::Error::UnprocessableEntity, 429 => EpoOps::Error::TooManyRequests, 500 => EpoOps::Error::InternalServerError, 502 => EpoOps::Error::BadGateway, 503 => EpoOps::Error::ServiceUnavailable, 504 => EpoOps::Error::GatewayTimeout }.freeze
- FORBIDDEN_MESSAGES =
{ 'This request has been rejected due to the violation of Fair Use policy' => EpoOps::Error::TooManyRequests }.freeze
Instance Attribute Summary collapse
- #code ⇒ Integer readonly
- #rate_limit ⇒ Integer readonly
Class Method Summary collapse
-
.from_response(response) ⇒ Error
Parses an error from the given response.
Instance Method Summary collapse
-
#initialize(message = '', rate_limit = {}, code = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
Instance Attribute Details
#code ⇒ Integer (readonly)
4 5 6 |
# File 'lib/epo_ops/error.rb', line 4 def code @code end |
#rate_limit ⇒ Integer (readonly)
4 5 6 |
# File 'lib/epo_ops/error.rb', line 4 def rate_limit @rate_limit end |
Class Method Details
.from_response(response) ⇒ Error
Parses an error from the given response
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/epo_ops/error.rb', line 55 def from_response(response) code = response.status = parse_error(response.parsed) if code == 403 && FORBIDDEN_MESSAGES[] FORBIDDEN_MESSAGES[].new(, response.headers, code) elsif code == 400 && response.headers['www-authenticate'] && response.headers['www-authenticate'].include?('Access Token expired') Error::AccessTokenExpired.new('Access Token expired', response.headers, code) else ERRORS[code].new(, response.headers, code) end end |