Exception: Twilio::REST::RestError

Inherits:
TwilioError
  • Object
show all
Defined in:
lib/twilio-ruby/framework/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, response) ⇒ RestError

Returns a new instance of RestError.



14
15
16
17
18
19
20
21
22
# File 'lib/twilio-ruby/framework/error.rb', line 14

def initialize(message, response)
  @status_code = response.status_code
  @code = response.body.fetch('code', @status_code)
  @detail = response.body.fetch('detail', nil)
  @error_message = response.body.fetch('message', nil)
  @more_info = response.body.fetch('more_info', nil)
  @message = format_message(message)
  @response = response
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



12
13
14
# File 'lib/twilio-ruby/framework/error.rb', line 12

def code
  @code
end

#detailObject (readonly)

Returns the value of attribute detail.



12
13
14
# File 'lib/twilio-ruby/framework/error.rb', line 12

def detail
  @detail
end

#error_messageObject (readonly)

Returns the value of attribute error_message.



12
13
14
# File 'lib/twilio-ruby/framework/error.rb', line 12

def error_message
  @error_message
end

#messageObject (readonly)

Returns the value of attribute message.



12
13
14
# File 'lib/twilio-ruby/framework/error.rb', line 12

def message
  @message
end

#more_infoObject (readonly)

Returns the value of attribute more_info.



12
13
14
# File 'lib/twilio-ruby/framework/error.rb', line 12

def more_info
  @more_info
end

#responseObject (readonly)

Returns the value of attribute response.



12
13
14
# File 'lib/twilio-ruby/framework/error.rb', line 12

def response
  @response
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



12
13
14
# File 'lib/twilio-ruby/framework/error.rb', line 12

def status_code
  @status_code
end

Instance Method Details

#bodyObject

Deprecated.

use #response instead



25
26
27
28
29
# File 'lib/twilio-ruby/framework/error.rb', line 25

def body
  warn 'This error used to be a "Twilio::REST::TwilioError" but is now a "Twilio::REST::RestError". ' \
       'Please use #response instead of #body.'
  @response
end

#to_sObject



31
32
33
# File 'lib/twilio-ruby/framework/error.rb', line 31

def to_s
  message
end