Exception: Recurly::Errors::APIError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/recurly/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, error) ⇒ APIError


20
21
22
23
24
# File 'lib/recurly/errors.rb', line 20

def initialize(response, error)
  super(error.message)
  @response = response
  @recurly_error = error
end

Instance Attribute Details

#recurly_errorObject

Returns the value of attribute recurly_error


6
7
8
# File 'lib/recurly/errors.rb', line 6

def recurly_error
  @recurly_error
end

Class Method Details

.error_class(error_key) ⇒ Errors::APIError, Errors::NetworkError

Looks up an Error class by name

Examples:

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

14
15
16
17
18
# 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

Instance Method Details

#get_responseObject


30
31
32
# File 'lib/recurly/errors.rb', line 30

def get_response
  @response
end

#status_codeObject


26
27
28
# File 'lib/recurly/errors.rb', line 26

def status_code
  @response.status
end