note 121228 added to language.exceptions
| From: | christof+php | Date: | Thu, 15 Jun 2017 10:12:35 +0000 |
| Subject: | note 121228 added to language.exceptions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209132@lists.php.net to get a copy of this message | ||
In case your E_WARNING type of errors aren't catchable with try/catch you can change them to
another type of error like this:
<?php
set_error_handler(function($errno, $errstr, $errfile, $errline){
if($errno === E_WARNING){
// make it more serious than a warning so it can be caught
trigger_error($errstr, E_ERROR);
return true;
} else {
// fallback to default php error handler
return false;
}
});
try {
// code that might result in a E_WARNING
} catch(Exception $e){
// code to handle the E_WARNING (it's actually changed to E_ERROR at this point)
} finally {
restore_error_handler();
}
?>
----
Server IP: 94.142.242.175
Probable Submitter: 81.82.207.237
----
Manual Page -- http://php.net/manual/en/language.exceptions.php
Edit -- https://master.php.net/note/edit/121228
Del: integrated -- https://master.php.net/note/delete/121228/integrated
Del: useless -- https://master.php.net/note/delete/121228/useless
Del: bad code -- https://master.php.net/note/delete/121228/bad+code
Del: spam -- https://master.php.net/note/delete/121228/spam
Del: non-english -- https://master.php.net/note/delete/121228/non-english
Del: in docs -- https://master.php.net/note/delete/121228/in+docs
Del: other reasons-- https://master.php.net/note/delete/121228
Reject -- https://master.php.net/note/reject/121228
Search -- https://master.php.net/manage/user-notes.php