Exception: VoiceML::ApiError

Inherits:
Error
  • Object
show all
Defined in:
lib/voiceml/errors.rb

Overview

Raised when the API returns a non-2xx response.

The Twilio-compatible error body (‘{ code, message, more_info, status }`) is parsed into `#code`, `#message`, and `#more_info` when present, with the raw payload exposed on `#body`. `#more_info` is the Twilio documentation URL for the error code (e.g. `www.twilio.com/docs/errors/20404`).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code:, code: nil, body: nil, more_info: nil) ⇒ ApiError

Returns a new instance of ApiError.



19
20
21
22
23
24
25
# File 'lib/voiceml/errors.rb', line 19

def initialize(message, status_code:, code: nil, body: nil, more_info: nil)
  super(message)
  @status_code = status_code
  @code        = code
  @body        = body
  @more_info   = more_info
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



17
18
19
# File 'lib/voiceml/errors.rb', line 17

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



17
18
19
# File 'lib/voiceml/errors.rb', line 17

def code
  @code
end

#more_infoObject (readonly)

Returns the value of attribute more_info.



17
18
19
# File 'lib/voiceml/errors.rb', line 17

def more_info
  @more_info
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



17
18
19
# File 'lib/voiceml/errors.rb', line 17

def status_code
  @status_code
end