Exception: Odnoklassniki::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Odnoklassniki::Error
- Defined in:
- lib/odnoklassniki/error.rb
Overview
Custom error class for rescuing from all Odnoklassniki errors
Defined Under Namespace
Modules: Code
Constant Summary collapse
- ClientError =
Raised when Odnoklassniki returns a 2xx HTTP status code
Class.new(self)
- BadRequest =
Raised when Odnoklassniki returns the HTTP status code 400
Class.new(ClientError)
Class.new(ClientError)
- Forbidden =
Raised when Odnoklassniki returns the HTTP status code 403
Class.new(ClientError)
- NotFound =
Raised when Odnoklassniki returns the HTTP status code 404
Class.new(ClientError)
- NotAcceptable =
Raised when Odnoklassniki returns the HTTP status code 406
Class.new(ClientError)
- UnprocessableEntity =
Raised when Odnoklassniki returns the HTTP status code 422
Class.new(ClientError)
- TooManyRequests =
Raised when Odnoklassniki returns the HTTP status code 429
Class.new(ClientError)
- ServerError =
Raised when Odnoklassniki returns a 5xx HTTP status code
Class.new(self)
- InternalServerError =
Raised when Odnoklassniki returns the HTTP status code 500
Class.new(ServerError)
- BadGateway =
Raised when Odnoklassniki returns the HTTP status code 502
Class.new(ServerError)
Class.new(ServerError)
- GatewayTimeout =
Raised when Odnoklassniki returns the HTTP status code 504
Class.new(ServerError)
- ERRORS =
{ 200 => Odnoklassniki::Error::ClientError, 400 => Odnoklassniki::Error::BadRequest, 401 => Odnoklassniki::Error::Unauthorized, 403 => Odnoklassniki::Error::Forbidden, 404 => Odnoklassniki::Error::NotFound, 406 => Odnoklassniki::Error::NotAcceptable, 422 => Odnoklassniki::Error::UnprocessableEntity, 429 => Odnoklassniki::Error::TooManyRequests, 500 => Odnoklassniki::Error::InternalServerError, 502 => Odnoklassniki::Error::BadGateway, 503 => Odnoklassniki::Error::ServiceUnavailable, 504 => Odnoklassniki::Error::GatewayTimeout, }
Instance Attribute Summary collapse
- #code ⇒ Integer readonly
Class Method Summary collapse
-
.from_response(body) ⇒ Odnoklassniki::Error
Create a new error from an HTTP response.
Instance Method Summary collapse
-
#initialize(message = '', code = nil) ⇒ Odnoklassniki::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(message = '', code = nil) ⇒ Odnoklassniki::Error
Initializes a new Error object
177 178 179 180 |
# File 'lib/odnoklassniki/error.rb', line 177 def initialize( = '', code = nil) super() @code = code end |
Instance Attribute Details
#code ⇒ Integer (readonly)
6 7 8 |
# File 'lib/odnoklassniki/error.rb', line 6 def code @code end |
Class Method Details
.from_response(body) ⇒ Odnoklassniki::Error
Create a new error from an HTTP response
160 161 162 |
# File 'lib/odnoklassniki/error.rb', line 160 def from_response(body) new(*parse_error(body)) end |