note 114707 added to class.pdoexception
| From: | radu.potopatwooptoo.com | Date: | Thu, 27 Mar 2014 07:56:55 +0000 |
| Subject: | note 114707 added to class.pdoexception | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199050@lists.php.net to get a copy of this message | ||
Since PDOException returns the error code as a string, you need a constructor like the one below if
you wish to rethrow the PDOException as a custom exception.
This constructor does not call the parent::__construct which will enforce the int type on the error
code, but set the message and code as properties directly on the custom exception object.
<?php
class CustomException extends PDOException {
/**
* Override constructor and set message and code properties.
* Workaround PHP BUGS #51742, #39615
*/
public function __construct($message=null, $code=null) {
$this->message = $message;
$this->code = $code;
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 86.120.44.61
----
Manual Page -- http://php.net/manual/en/class.pdoexception.php
Edit -- https://master.php.net/note/edit/114707
Del: integrated -- https://master.php.net/note/delete/114707/integrated
Del: useless -- https://master.php.net/note/delete/114707/useless
Del: bad code -- https://master.php.net/note/delete/114707/bad+code
Del: spam -- https://master.php.net/note/delete/114707/spam
Del: non-english -- https://master.php.net/note/delete/114707/non-english
Del: in docs -- https://master.php.net/note/delete/114707/in+docs
Del: other reasons-- https://master.php.net/note/delete/114707
Reject -- https://master.php.net/note/reject/114707
Search -- https://master.php.net/manage/user-notes.php