class Epages::Error

Constants

BadGateway
BadRequest

HTTP status code 400, 401, 403, 404, 405, 406, 409, 410, 422, 429 respectively

ClientError

Raised when a 4xx HTTP status code is returned

Conflict
ERRORS
Forbidden
GatewayTimeout
Gone
InternalServerError

HTTP status code 500, 502, 503, 504 respectively

MethodNotAllowed
NotAcceptable
NotFound
ServerError

Raised when a 5xx HTTP status code is returned

ServiceUnavailable
TooManyRequests
Unauthorized
UnprocessableEntity

Attributes

code[R]

Private Instance Methods

extract_message_from_errors(body) click to toggle source
# File lib/epages/error.rb, line 58
def extract_message_from_errors(body)
  first = Array(body[:errors]).first
  if first.is_a?(Hash)
    [first[:message].chomp, first[:code]]
  else
    [first.chomp, nil]
  end
end
parse_error(body) click to toggle source
# File lib/epages/error.rb, line 48
def parse_error(body)
  if body.nil? || body.empty?
    ['', nil]
  elsif body[:error]
    [body[:error], nil]
  elsif body[:errors]
    extract_message_from_errors(body)
  end
end