class Odnoklassniki::Error

Custom error class for rescuing from all Odnoklassniki errors

Constants

BadGateway

Raised when Odnoklassniki returns the HTTP status code 502

BadRequest

Raised when Odnoklassniki returns the HTTP status code 400

ClientError

Raised when Odnoklassniki returns a 2xx HTTP status code

ERRORS
Forbidden

Raised when Odnoklassniki returns the HTTP status code 403

GatewayTimeout

Raised when Odnoklassniki returns the HTTP status code 504

InternalServerError

Raised when Odnoklassniki returns the HTTP status code 500

NotAcceptable

Raised when Odnoklassniki returns the HTTP status code 406

NotFound

Raised when Odnoklassniki returns the HTTP status code 404

ServerError

Raised when Odnoklassniki returns a 5xx HTTP status code

ServiceUnavailable

Raised when Odnoklassniki returns the HTTP status code 503

TooManyRequests

Raised when Odnoklassniki returns the HTTP status code 429

Unauthorized

Raised when Odnoklassniki returns the HTTP status code 401

UnprocessableEntity

Raised when Odnoklassniki returns the HTTP status code 422

Attributes

code[R]

@return [Integer]

Public Class Methods

from_response(body) click to toggle source

Create a new error from an HTTP response

@param response [HTTP::Response] @return [Odnoklassniki::Error]

# File lib/odnoklassniki/error.rb, line 160
def from_response(body)
  new(*parse_error(body))
end
new(message = '', code = nil) click to toggle source

Initializes a new Error object

@param message [Exception, String] @param code [Integer] @return [Odnoklassniki::Error]

Calls superclass method
# File lib/odnoklassniki/error.rb, line 177
def initialize(message = '', code = nil)
  super(message)
  @code = code
end

Private Class Methods

parse_error(body) click to toggle source
# File lib/odnoklassniki/error.rb, line 166
def parse_error(body)
  [body['error_msg'].to_s, body['error_code']]
end