Exception: EventbriteSDK::EventbriteAPIError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/eventbrite_sdk/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/eventbrite_sdk/exceptions.rb', line 3

def message
  @message
end

#responseObject (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_errorObject

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": "#{message}"})
  value = response_value(:body, fallback: default)

  JSON.parse(value)
end

#status_codeObject

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