Exception: Glassfrog::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Glassfrog::Error
- Defined in:
- lib/glassfrog/error.rb
Overview
Encapsulates GlassFrog HTTP errors.
Constant Summary collapse
- ClientError =
Raised with a 4xx HTTP status code
Class.new(self)
- BadRequest =
Raised with the HTTP status code 400
Class.new(ClientError)
Class.new(ClientError)
- Forbidden =
Raised with the HTTP status code 403
Class.new(ClientError)
- NotFound =
Raised with the HTTP status code 404
Class.new(ClientError)
- NotAcceptable =
Raised with the HTTP status code 406
Class.new(ClientError)
- UnprocessableEntity =
Raised with the HTTP status code 422
Class.new(ClientError)
- TooManyRequests =
Raised with the HTTP status code 429
Class.new(ClientError)
- ServerError =
Raised with a 5xx HTTP status code
Class.new(self)
- InternalServerError =
Raised with the HTTP status code 500
Class.new(ServerError)
- BadGateway =
Raised with the HTTP status code 502
Class.new(ServerError)
Class.new(ServerError)
- GatewayTimeout =
Raised with the HTTP status code 504
Class.new(ServerError)
- ERRORS =
{ 400 => Glassfrog::Error::BadRequest, 401 => Glassfrog::Error::Unauthorized, 403 => Glassfrog::Error::Forbidden, 404 => Glassfrog::Error::NotFound, 406 => Glassfrog::Error::NotAcceptable, 422 => Glassfrog::Error::UnprocessableEntity, 429 => Glassfrog::Error::TooManyRequests, 500 => Glassfrog::Error::InternalServerError, 502 => Glassfrog::Error::BadGateway, 503 => Glassfrog::Error::ServiceUnavailable, 504 => Glassfrog::Error::GatewayTimeout, }
Instance Attribute Summary collapse
- #code ⇒ Integer readonly
Class Method Summary collapse
-
.from_response(code, body, headers) ⇒ Glassfrog::Error
Create a new error from an HTTP response.
Instance Method Summary collapse
-
#initialize(message = '', code = nil) ⇒ Glassfrog::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(message = '', code = nil) ⇒ Glassfrog::Error
Initializes a new Error object.
92 93 94 95 |
# File 'lib/glassfrog/error.rb', line 92 def initialize( = '', code = nil) super() @code = code end |
Instance Attribute Details
#code ⇒ Integer (readonly)
7 8 9 |
# File 'lib/glassfrog/error.rb', line 7 def code @code end |
Class Method Details
.from_response(code, body, headers) ⇒ Glassfrog::Error
Create a new error from an HTTP response.
61 62 63 64 |
# File 'lib/glassfrog/error.rb', line 61 def from_response(code, body, headers) = parse_error(code, body, headers) new(, code) end |