diff --git a/mongodb.module b/mongodb.module
index 38823ff..0ba1021 100644
--- a/mongodb.module
+++ b/mongodb.module
@@ -36,10 +36,19 @@ function mongodb($alias = 'default') {
   $host = $connection['host'];
   $db = $connection['db'];
   if (!isset($mongo_objects[$host][$db])) {
-    $mongo = new Mongo($host);
-    $mongo_objects[$host][$db] = $mongo->selectDB($db);
-    $mongo_objects[$host][$db]->connection = $mongo;
+    try {
+      $mongo = new Mongo($host);
+      $mongo_objects[$host][$db] = $mongo->selectDB($db);
+      $mongo_objects[$host][$db]->connection = $mongo;
+    }
+    catch (Exception $e) {
+      // We failed the instentiate the Mongo object - log and error and return FALSE
+      $mongo_objects[$host][$db] = FALSE;
+      watchdog('mongodb',$e->getMessage(), NULL, WATCHDOG_ERROR);
+      return FALSE;
+    }
   }
+  
   return $mongo_objects[$host][$db];
 }
 
@@ -67,6 +76,7 @@ function mongodb_collection() {
   // non-prefixed version so it's enough to prefix after choosing the mongodb
   // object.
   $mongodb_object = mongodb($alias);
+  if (!$mongodb_object) return FALSE;
   $collection = $mongodb_object->selectCollection(mongodb_collection_name($collection_name));
   $collection->connection = $mongodb_object->connection;
   return variable_get('mongodb_debug', FALSE) ? new mongoDebugCollection($collection) : $collection;
diff --git a/mongodb_watchdog/mongodb_watchdog.module b/mongodb_watchdog/mongodb_watchdog.module
index 428ec31..6e2fd42 100644
--- a/mongodb_watchdog/mongodb_watchdog.module
+++ b/mongodb_watchdog/mongodb_watchdog.module
@@ -111,16 +111,19 @@ function mongodb_watchdog_watchdog(array $log_entry) {
     '$inc' => array('count' => 1),
   );
   $collection = mongodb_collection(variable_get('mongodb_watchdog', 'watchdog'));
-  $id = md5($log_entry['function'] . ':' . $log_entry['line'] . ':' . $log_entry['severity'] . ':' . $log_entry['type'] . ':' . $log_entry['message']);
-  $collection->update(array('_id' => $id), $newobj, array('upsert' => TRUE));
-  $result = $collection->db->command(array('getlasterror' => 1));
-  $collection = $collection->db->selectCollection('watchdog_event_' . $id);
-  if (empty($result['updatedExisting'])) {
-    $max = variable_get('mongodb_watchdog_items', 10000);
-    $command = array('create' => $collection->getName(), 'capped' => TRUE, 'size' => $max * 1000, "max" => $max);
-    $collection->db->command($command);
+  if ($collection) {
+    $id = md5($log_entry['function'] . ':' . $log_entry['line'] . ':' . $log_entry['severity'] . ':' . $log_entry['type'] . ':' . $log_entry['message']);
+    $collection->update(array('_id' => $id), $newobj, array('upsert' => TRUE));
+    $result = $collection->db->command(array('getlasterror' => 1));
+    $collection = $collection->db->selectCollection('watchdog_event_' . $id);
+    if (empty($result['updatedExisting'])) {
+      $max = variable_get('mongodb_watchdog_items', 10000);
+      $command = array('create' => $collection->getName(), 'capped' => TRUE, 'size' => $max * 1000, "max" => $max);
+      $collection->db->command($command);
+    }
+    $collection->insert($event);
   }
-  $collection->insert($event);
+  else drupal_set_message('Error: Unable to connect to MongoDB collection to log watchdog message','error');
 }
 
 /**
