title: Cannot catch MongoConnectionException
body: <p>I am getting MongoConnectionException on trying to connect to mongodb server, when mongod is not running. Unfortunately, I am unable to catch the exception. Can someone tell me what is wrong with the following code?</p>
  
  <pre><code>try {
      $conn = new \Mongo('localhost');
      self::$mdb = $conn-&gt;filestore;
  } catch(MongoConnectionException $e) {
      trigger_error('Mongodb not available', E_USER_ERROR);
  }
  </code></pre>
  
  <p>The above code fails with the Exception </p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'MongoConnectionException' with
    message 'Invalid argument'</p>
  </blockquote>
  
  <p>I tried to catch the exception using MongoConnectionException and Exception classes, but both are not working.</p>