class Snitcher::API::Error
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.
Attributes
type[R]
Public Class Methods
new(api_error)
click to toggle source
# File lib/snitcher/api/error.rb, line 11 def self.new(api_error) type = api_error.delete("type") message = 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 when "internal_server_error"; InternalServerError else Error end error = klass.allocate error.send(:initialize, type, message, api_error) error end
new(type, message = nil, metadata = nil)
click to toggle source
Calls superclass method
# File lib/snitcher/api/error.rb, line 34 def initialize(type, message = nil, metadata = nil) super(message) @type = type @metadata = metadata || {} end