Alcaeus\MongoDbAdapter\ExceptionConverter::toResultArray PHP Method

toResultArray() public static method

Converts an exception to
public static toResultArray ( MongoDB\Driver\Exception\Exception $e ) : array
$e MongoDB\Driver\Exception\Exception
return array
    public static function toResultArray(Exception\Exception $e)
    {
        return ['ok' => 0.0, 'errmsg' => $e->getMessage(), 'code' => $e->getCode()];
    }

Usage Example

Example #1
0
 /**
  * Execute a database command
  *
  * @link http://www.php.net/manual/en/mongodb.command.php
  * @param array $data The query to send.
  * @param array $options
  * @return array Returns database response.
  */
 public function command(array $data, $options = [], &$hash = null)
 {
     try {
         $cursor = new \MongoCommandCursor($this->connection, $this->name, $data);
         $cursor->setReadPreference($this->getReadPreference());
         return iterator_to_array($cursor)[0];
     } catch (\MongoDB\Driver\Exception\Exception $e) {
         return ExceptionConverter::toResultArray($e);
     }
 }
All Usage Examples Of Alcaeus\MongoDbAdapter\ExceptionConverter::toResultArray
ExceptionConverter