diff --git a/sites/all/modules/contrib/sms_twilio/sms_twilio.module b/sites/all/modules/contrib/sms_twilio/sms_twilio.module
index 65e53eb..e54df39 100755
--- a/sites/all/modules/contrib/sms_twilio/sms_twilio.module
+++ b/sites/all/modules/contrib/sms_twilio/sms_twilio.module
@@ -123,40 +123,45 @@ function sms_twilio_command($command = 'auth', $data = array(), $config = NULL,
   // Instantiate a new Twilio Rest Client
   $client = new Client($AccountSid, $AuthToken);
 
-  switch ($command) {
-    case 'sendmsg':
-      $response = $client->messages->create(
-        $data['number'],
-        array(
-          'from' => $config['sms_twilio_number'],
-          'body' => $data['message'],
-        )
-      );
-      break;
+  try {
+    switch ($command) {
+      case 'sendmsg':
+        $response = $client->messages->create(
+          $data['number'],
+          array(
+            'from' => $config['sms_twilio_number'],
+            'body' => $data['message'],
+          )
+        );
+        break;
+    }
   }
-
-  watchdog('sms_twilio', print_r($response, TRUE));
-  // Check for HTTP errors
-  if ($response->errorCode != '') {
+  catch (Exception $e) {
+    // Twilio threw an exception.
+    $error_code = $e->getCode();
+    $error = $e->getMessage();
     $result = array(
       'status' => FALSE,
+      'error_code' => $error_code,
+      'error' => $error,
       'message' => t('An error occurred during the HTTP request: @error_code: @error.  Please see <a href="@twilio_url">the Twilio docs</a> for more information',
         array(
-          '@error_code' => $response->errorCode,
-          '@error' => $response->errorMessage,
+          '@error_code' => $error_code,
+          '@error' => $error,
           '@twilio_url' => 'https://www.twilio.com/docs/api/rest/message#error-values'
         )
       ),
     );
 
     watchdog('sms_twilio', $result['message']);
+
+    return $result;
   }
-  else {
-    $result = array(
-      'status' => TRUE,
-      'data' => t('Message sent to @number', array('@number' => $data['number'])),
-    );
-  }
+
+  $result = array(
+    'status' => TRUE,
+    'data' => t('Message sent to @number', array('@number' => $data['number'])),
+  );
 
   return $result;
 }
