class Croudia::Error

Constants

BadGateway
BadRequest

400 ~

ClientError
ERRORS
Forbidden
GatewayTimeout
Gone
InternalServerError

500 ~

NotAcceptable
NotFound
ServerError
ServiceUnavailable
TooManyRequests
Unauthorized
UnprocessableEntity

Attributes

code[R]
message[R]

Public Class Methods

from_response(response) click to toggle source
# File lib/croudia/error.rb, line 50
def from_response(response)
  if (response.body.nil? || response.body.strip.empty?)
    ERRORS[response.code.to_s].new(response.code, 'No message')
  else
    json = JSON.parse(response.body)
    if(json['error'])
      message = json['error']
    else
      message = json['message']
    end
    ERRORS[response.code.to_s].new(response.code, message)
  end
end
new(code, message) click to toggle source
Calls superclass method
# File lib/croudia/error.rb, line 42
def initialize(code, message)
  super(message)

  @code = code
  @message = message
end