Exception: EventbriteSDK::EventbriteAPIError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- EventbriteSDK::EventbriteAPIError
- Defined in:
- lib/eventbrite_sdk/exceptions.rb
Direct Known Subclasses
BadRequest, Forbidden, InternalServerError, InvalidAttribute, ResourceNotFound, Unauthorized
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(msg = '', response = :none) ⇒ EventbriteAPIError
constructor
A new instance of EventbriteAPIError.
-
#parsed_error ⇒ Object
Returns a hash with AT LEAST ‘error_description’.
-
#status_code ⇒ Object
Returns the status code of the response, or :none if there is no response.
Constructor Details
#initialize(msg = '', response = :none) ⇒ EventbriteAPIError
Returns a new instance of EventbriteAPIError.
5 6 7 8 |
# File 'lib/eventbrite_sdk/exceptions.rb', line 5 def initialize(msg = '', response = :none) @message = msg @response = response end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/eventbrite_sdk/exceptions.rb', line 3 def @message end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/eventbrite_sdk/exceptions.rb', line 3 def response @response end |
Instance Method Details
#parsed_error ⇒ Object
Returns a hash with AT LEAST ‘error_description’. When an error is raised manually there will be no response! This is handled by using the specified message as the error_description.
13 14 15 16 17 18 |
# File 'lib/eventbrite_sdk/exceptions.rb', line 13 def parsed_error default = %({"error_description": "#{}"}) value = response_value(:body, fallback: default) JSON.parse(value) end |
#status_code ⇒ Object
Returns the status code of the response, or :none if there is no response.
21 22 23 |
# File 'lib/eventbrite_sdk/exceptions.rb', line 21 def status_code response_value(:code) end |