lib/models/phone.rb in devise_phone-0.1.1 vs lib/models/phone.rb in devise_phone-0.1.2

- old
+ new

@@ -99,16 +99,21 @@ twilio_sid = Rails.application.config.twilio[:sid] twilio_token = Rails.application.config.twilio[:token] twilio_phone_number = Rails.application.config.twilio[:phone_number] twilio_message_body = I18n.t("devise.phone.message_body", :verification_code => verification_code) - @twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token - - @twilio_client.account.messages.create( - :from => "+1#{twilio_phone_number}", - :to => number_to_send_to, - :body => twilio_message_body - ) + begin + @twilio_client = Twilio::REST::Client.new twilio_sid, twilio_token + @twilio_client.account.messages.create( + :from => "+1#{twilio_phone_number}", + :to => number_to_send_to, + :body => twilio_message_body + ) + nil #return nil indicating sms sent successfully + rescue Twilio::REST::RequestError => e + e.message + end + end end end end