private function _exception_management(\MongoException $e)
 {
     switch ($e->getCode()) {
         case '1':
             $type = 'wrong_key';
             $message = 'You are trying to save a document with empty key';
             break;
         case '2':
             $type = 'wrong_key';
             $message = 'You are trying to save a document with not allowed format key : ' . $e->getMessage();
             break;
         case '3':
             $type = 'invalid_parameters';
             $message = 'Insert or update parameters weight is too big : ' . $e->getMessage();
             break;
         case '4':
             $type = 'invalid_parameters';
             $message = 'You are trying to save an empty document : ' . $e->getMessage();
             break;
         case '5':
             $type = 'wrong_key';
             $message = 'You are trying to save a document with non string keys : ' . $e->getMessage();
             break;
         default:
             $type = 'data_storage_exception';
             $message = $e->getMessage();
     }
     throw $this->except($message, $type);
 }
Example #2
0
 /**
  * Returns the last error code
  *
  * @return int
  */
 public function last_error_code()
 {
     return is_object($this->_last_error) ? $this->_last_error->getCode() : 0;
 }