Class: RDStation::ErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/rdstation/error_handler.rb,
lib/rdstation/error_handler/bad_request.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/invalid_event_type.rb,
lib/rdstation/error_handler/invalid_credentials.rb,
lib/rdstation/error_handler/expired_access_token.rb,
lib/rdstation/error_handler/invalid_refresh_token.rb

Defined Under Namespace

Classes: BadRequest, ConflictingField, ExpiredAccessToken, ExpiredCodeGrant, InvalidCredentials, InvalidEventType, InvalidRefreshToken, Unauthorized

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ErrorHandler

Returns a new instance of ErrorHandler.



7
8
9
10
# File 'lib/rdstation/error_handler.rb', line 7

def initialize(response)
  @response = response
  @code = response.code
end

Instance Method Details

#raise_errorObject



12
13
14
15
16
17
18
# File 'lib/rdstation/error_handler.rb', line 12

def raise_error
  raise error_class, array_of_errors.first if error_class < RDStation::Error

  error_class.new(array_of_errors).raise_error
rescue JSON::ParserError => error
  raise error_class, { 'error_message' => response.body }
end