3

I keep getting the same error since I upgraded to:

gem 'twilio-ruby', '~> 5.0.0.rc4'

The call was successful set to Twilio, but the getting some error.

app/controllers/home_controller.rb:59:in `rescue in call'

require "rubygems"
require "twilio-ruby"

def call
  @twilio = Twilio::REST::Client.new account_sid, auth_token

  begin
    @call = @twilio.account.calls.create({
     :to => , 
      :from => twilio_number,
      :url => url,
      :method => "GET",
      :if_machine => "Hangup",
      :timeout => "20"
    })

    # Getting current call status (seems like error here...!)
    get_status(@call.sid)

  rescue Twilio::REST::RequestError => error
    @err_msg = error.message
    puts @err_msg
    #returned error is like below:
    #NameError (uninitialized constant Twilio::REST::RequestError)
  end
end

Code for getting current call status:

def get_status(sid)
  @twilio = Twilio::REST::Client.new account_sid, auth_token
  @call = @twilio.account.calls.get(sid)
  puts "Process Status : " + @call.status
  return @call.status
end

Please help to figure it out.

Thank you!

aldrien.h
  • 3,437
  • 2
  • 30
  • 52

1 Answers1

2

For version 5, Try Twilio::REST::RestError.

This is documented here:

There are new classes to rescue errors from. The new library now uses the Twilio::REST::RestError class.

Matan Shahar
  • 3,190
  • 2
  • 20
  • 45
sweta
  • 29
  • 3