Skip to content

Instantly share code, notes, and snippets.

@jeremysells
Created October 5, 2019 13:21
Show Gist options
  • Save jeremysells/f555c40bcd42e880c9f716e517a0fb31 to your computer and use it in GitHub Desktop.
Save jeremysells/f555c40bcd42e880c9f716e517a0fb31 to your computer and use it in GitHub Desktop.
php exception error handler
<?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