Created
October 5, 2019 13:21
-
-
Save jeremysells/f555c40bcd42e880c9f716e517a0fb31 to your computer and use it in GitHub Desktop.
php exception error handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
error_reporting(E_ALL); | |
set_error_handler(function ($severity, $message, $file, $line) { | |
if (!(error_reporting() & $severity)) { | |
// This error code is not included in error_reporting | |
return; | |
} | |
throw new \ErrorException($message, 0, $severity, $file, $line); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment