Skip to content

Instantly share code, notes, and snippets.

@GromNaN
Created July 20, 2020 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GromNaN/7f41f73cc22f788009b26e582cdbb887 to your computer and use it in GitHub Desktop.
Save GromNaN/7f41f73cc22f788009b26e582cdbb887 to your computer and use it in GitHub Desktop.
Autoload error handler
{
"name": "<to-be-defined>",
"type": "library",
"license": "MIT",
"autoload": {
"files": [ "handler.php" ]
}
}
<?php
/**
* Convert error to exception.
*
* @author Frédéric Bouchery
* @link https://twitter.com/FredBouchery/status/1285210405317615617/photo/1
*/
\set_error_handler(function ($severity, $message, $file, $line) {
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