Class: RDStation::ErrorHandler::Unauthorized
- Inherits:
-
Object
- Object
- RDStation::ErrorHandler::Unauthorized
- Defined in:
- lib/rdstation/error_handler/unauthorized.rb
Constant Summary collapse
- ERROR_CODE =
'UNAUTHORIZED'.freeze
- EXCEPTION_CLASS =
RDStation::Error::Unauthorized
Instance Attribute Summary collapse
-
#api_response ⇒ Object
readonly
Returns the value of attribute api_response.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
Instance Method Summary collapse
-
#initialize(api_response) ⇒ Unauthorized
constructor
A new instance of Unauthorized.
- #raise_error ⇒ Object
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
14 15 16 17 |
# File 'lib/rdstation/error_handler/unauthorized.rb', line 14 def raise_error return unless raise EXCEPTION_CLASS.new(error['error_message'], api_response) end |