Class: RDStation::ErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/rdstation/error_handler.rb,
lib/rdstation/error_handler/default.rb,
lib/rdstation/error_handler/unauthorized.rb,
lib/rdstation/error_handler/conflicting_field.rb,
lib/rdstation/error_handler/expired_code_grant.rb,
lib/rdstation/error_handler/resource_not_found.rb,
lib/rdstation/error_handler/invalid_credentials.rb,
lib/rdstation/error_handler/expired_access_token.rb

Defined Under Namespace

Classes: ConflictingField, Default, ExpiredAccessToken, ExpiredCodeGrant, InvalidCredentials, ResourceNotFound, Unauthorized

Constant Summary collapse

ERROR_TYPES =
[
  ErrorHandler::ConflictingField,
  ErrorHandler::ExpiredAccessToken,
  ErrorHandler::ExpiredCodeGrant,
  ErrorHandler::InvalidCredentials,
  ErrorHandler::ResourceNotFound,
  ErrorHandler::Unauthorized,
  ErrorHandler::Default
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ErrorHandler

Returns a new instance of ErrorHandler.



21
22
23
# File 'lib/rdstation/error_handler.rb', line 21

def initialize(response)
  @response = response
end

Instance Method Details

#raise_errors ⇒ Object



25
26
27
28
29
30
# File 'lib/rdstation/error_handler.rb', line 25

def raise_errors
  errors.each(&:raise_error)
  # Raise only the exception message when the error is not recognized
  unrecognized_error = @response['errors']
  raise unrecognized_error['error_message']
end