Exception: Snitcher::API::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Snitcher::API::Error
- Defined in:
- lib/snitcher/api/error.rb
Overview
Error is the base class for all API specific errors. For a full list of errors and how they can happen please refer to the API documentation.
Direct Known Subclasses
AccountOnHoldError, AuthenticationError, InternalServerError, PlanLimitReachedError, ResourceInvalidError, ResourceNotFoundError
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, message = nil, metadata = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(type, message = nil, metadata = nil) ⇒ Error
Returns a new instance of Error.
31 32 33 34 35 36 |
# File 'lib/snitcher/api/error.rb', line 31 def initialize(type, = nil, = nil) super() @type = type @metadata = || {} end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/snitcher/api/error.rb', line 7 def type @type end |
Class Method Details
.new(api_error) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/snitcher/api/error.rb', line 9 def self.new(api_error) type = api_error.delete("type") = api_error.delete("error") klass = case type.to_s # sign_in_incorrect is only returned when using username + password. when "sign_in_incorrect"; AuthenticationError # api_key_invalid is only returned when using the API key. when "api_key_invalid"; AuthenticationError when "plan_limit_reached"; PlanLimitReachedError when "account_on_hold"; AccountOnHoldError when "resource_not_found"; ResourceNotFoundError when "resource_invalid"; ResourceInvalidError else Error end error = klass.allocate error.send(:initialize, type, , api_error) error end |