This is an old question, but there is another subtle way this message can happen. He explained pretty well here in the docs .
Imagine this scenario:
try { // code that triggers a pdo exception } catch (Exception $e) { throw new MyCustomExceptionHandler($e); }
And MyCustomExceptionHandler is defined something like this:
class MyCustomExceptionHandler extends Exception { public function __construct($e) { parent::__construct($e->getMessage(), $e->getCode()); } }
This will lead to a new exception in a special exception handler, because the Exception class expects a number for the second parameter in its constructor, but a PDOException can dynamically change the return type $e->getCode() to a string.
The workaround for this will be determined by your custom exception handler, for example:
class MyCustomExceptionHandler extends Exception { public function __construct($e) { parent::__construct($e->getMessage()); $this->code = $e->getCode(); } }
Parris Varney Apr 23 '15 at 13:29 2015-04-23 13:29
source share