Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Created September 13, 2012 21:20
Show Gist options
  • Select an option

  • Save RobSpectre/3717756 to your computer and use it in GitHub Desktop.

Select an option

Save RobSpectre/3717756 to your computer and use it in GitHub Desktop.
Example of catching Twilio REST exceptions in Ruby - sketch, I don't actually know how this works.
require 'rubygems' # not necessary with ruby 1.9 but included for completeness
require 'twilio-ruby'
# put your own credentials here
account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
# set up a client to talk to the Twilio REST API
@client = Twilio::REST::Client.new account_sid, auth_token
begin
@client.account.sms.messages.create(
:from => '+14159341234',
:to => '+16105557069',
:body => 'Hey there!'
)
rescue Twilio::REST::RequestError => e
# do whatever you need to accept the failure gracefully
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment