note 89221 deleted from class.errorexception by googleguy
| From: | googleguy@php.net | Date: | Wed, 12 Sep 2012 03:38:31 +0000 |
| Subject: | note 89221 deleted from class.errorexception by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190635@lists.php.net to get a copy of this message | ||
Note Submitter: e dot sand at elisand dot com
----
If you're looking for a quick one-line way to change all errors in to Exceptions, you can do it
this way:
set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0,
$a, $c, $d);'), E_ALL);
using create_function() saves you a few lines of code by embedding it all in to a single line, plus
saves your namespace from a function name that should only ever be called in the event of an error
(this saves from direct invocation).