Class: RDStation::ErrorHandler::Unauthorized

Inherits:
Object
  • Object
show all
Defined in:
lib/rdstation/error_handler/unauthorized.rb

Constant Summary collapse

ERROR_CODE =
'UNAUTHORIZED'.freeze
EXCEPTION_CLASS =
RDStation::Error::Unauthorized

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_response) ⇒ Unauthorized

Returns a new instance of Unauthorized.



9
10
11
12
# File 'lib/rdstation/error_handler/unauthorized.rb', line 9

def initialize(api_response)
  @api_response = api_response
  @error = JSON.parse(api_response.body)['errors']
end

Instance Attribute Details

#api_response ⇒ Object (readonly)

Returns the value of attribute api_response.



4
5
6
# File 'lib/rdstation/error_handler/unauthorized.rb', line 4

def api_response
  @api_response
end

#error ⇒ Object (readonly)

Returns the value of attribute error.



4
5
6
# File 'lib/rdstation/error_handler/unauthorized.rb', line 4

def error
  @error
end

#response_body ⇒ Object (readonly)

Returns the value of attribute response_body.



4
5
6
# File 'lib/rdstation/error_handler/unauthorized.rb', line 4

def response_body
  @response_body
end

Instance Method Details

#raise_error ⇒ Object

Raises:



14
15
16
17
# File 'lib/rdstation/error_handler/unauthorized.rb', line 14

def raise_error
  return unless unauthorized?
  raise EXCEPTION_CLASS.new(error['error_message'], api_response)
end