note 104545 added to language.operators.errorcontrol
| From: | bohwaz at osu1 dot php dot net | Date: | Wed, 22 Jun 2011 13:27:55 +0000 |
| Subject: | note 104545 added to language.operators.errorcontrol | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180841@lists.php.net to get a copy of this message | ||
If you use the ErrorException exception to have a unified error management, I'll advise you to
test against error_reporting in the error handler, not in the exception handler as you might
encounter some headaches like blank pages as error_reporting might not be transmitted to exception
handler.
So instead of :
<?php
function exception_error_handler($errno, $errstr, $errfile, $errline )
{
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
function catchException($e)
{
if (error_reporting() === 0)
{
return;
}
// Do some stuff
}
set_exception_handler('catchException');
?>
It would be better to do :
<?php
function exception_error_handler($errno, $errstr, $errfile, $errline )
{
if (error_reporting() === 0)
{
return;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
function catchException($e)
{
// Do some stuff
}
set_exception_handler('catchException');
?>
----
Server IP: 195.221.21.36
Probable Submitter: 178.33.167.117
----
Manual Page -- http://www.php.net/manual/en/language.operators.errorcontrol.php
Edit -- https://master.php.net/note/edit/104545
Del: integrated -- https://master.php.net/note/delete/104545/integrated
Del: useless -- https://master.php.net/note/delete/104545/useless
Del: bad code -- https://master.php.net/note/delete/104545/bad+code
Del: spam -- https://master.php.net/note/delete/104545/spam
Del: non-english -- https://master.php.net/note/delete/104545/non-english
Del: in docs -- https://master.php.net/note/delete/104545/in+docs
Del: other reasons-- https://master.php.net/note/delete/104545
Reject -- https://master.php.net/note/reject/104545
Search -- https://master.php.net/manage/user-notes.php