Paul on Nostr: If you're writing PHP, I highly recommend adding this snippet to the top of a common ...
If you're writing PHP, I highly recommend adding this snippet to the top of a common include file:
set_error_handler(
function ($severity, $message, $file, $line) {
throw new \ErrorException($message, $severity, $severity, $file, $line);
}
);
It turns all warnings and errors (if you've set E_ALL) into exceptions, which means they blow up your scripts immediately and give you a full stack trace, rather than just the line the error occurred on.
#PHP
set_error_handler(
function ($severity, $message, $file, $line) {
throw new \ErrorException($message, $severity, $severity, $file, $line);
}
);
It turns all warnings and errors (if you've set E_ALL) into exceptions, which means they blow up your scripts immediately and give you a full stack trace, rather than just the line the error occurred on.
#PHP