Exception: Recurly::Errors::APIError
- Inherits:
-
StandardError
- Object
- StandardError
- Recurly::Errors::APIError
- Defined in:
- lib/recurly/errors.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#recurly_error ⇒ Object
Returns the value of attribute recurly_error.
Class Method Summary collapse
-
.error_class(error_key) ⇒ Errors::APIError, Errors::NetworkError
Looks up an Error class by name.
-
.from_response(response) ⇒ Errors::APIError
When the response does not have a JSON body, this determines the appropriate Error class based on the response code.
Instance Method Summary collapse
- #get_response ⇒ Object
-
#initialize(message, response = nil, error = nil) ⇒ APIError
constructor
A new instance of APIError.
- #status_code ⇒ Object
Constructor Details
#initialize(message, response = nil, error = nil) ⇒ APIError
Returns a new instance of APIError.
33 34 35 36 37 |
# File 'lib/recurly/errors.rb', line 33 def initialize(, response = nil, error = nil) super() @response = response @recurly_error = error end |
Instance Attribute Details
#recurly_error ⇒ Object
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
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 |
.from_response(response) ⇒ Errors::APIError
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.
25 26 27 28 29 30 31 |
# 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 |
Instance Method Details
#get_response ⇒ Object
43 44 45 |
# File 'lib/recurly/errors.rb', line 43 def get_response @response end |
#status_code ⇒ Object
39 40 41 |
# File 'lib/recurly/errors.rb', line 39 def status_code @response.status end |