class Recurly::Errors::APIError

Attributes

recurly_error[R]

@!attribute recurly_error

@return [Recurly::Resources::Error] The {Recurly::Resources::Error} object

Public Class Methods

error_class(error_key) click to toggle source

Looks up an Error class by name @example

Errors.error_class('BadRequestError')
#=> Errors::BadRequestError

@param error_key [String] @return [Errors::APIError,Errors::NetworkError]

# File lib/recurly/errors.rb, line 14
def self.error_class(error_key)
  class_name = error_key.split("_").map(&:capitalize).join
  class_name += "Error" unless class_name.end_with?("Error")
  Errors.const_get(class_name)
end
from_response(response) click to toggle source

When the response does not have a JSON body, this determines the appropriate Error class based on the response code. This may occur when a load balancer returns an error before it reaches Recurly’s API. @param response [Net::Response] @return [Errors::APIError]

# File lib/recurly/errors.rb, line 25
def self.from_response(response)
  if Recurly::Errors::ERROR_MAP.has_key?(response.code)
    Recurly::Errors.const_get(Recurly::Errors::ERROR_MAP[response.code])
  else
    Recurly::Errors::APIError
  end
end
new(message, response = nil, error = nil) click to toggle source
Calls superclass method
# File lib/recurly/errors.rb, line 33
def initialize(message, response = nil, error = nil)
  super(message)
  @response = response
  @recurly_error = error
end

Public Instance Methods

get_response() click to toggle source
# File lib/recurly/errors.rb, line 43
def get_response
  @response
end
status_code() click to toggle source
# File lib/recurly/errors.rb, line 39
def status_code
  @response.status
end