1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-15 02:47:02 +01:00
psalm/src/Psalm/Internal/exception_handler.php
Tyson Andre b713066d32 Add an exception handler that prints full exception trace (#2418)
By default, php will only print the first few thousand bytes of the
exception, for an uncaught exception
(I think that's the default, and not just my configuration)

Instead, print all of the parts of the exception.

For #1083 (this PR does not cover set_error_handler)
2019-12-04 23:17:08 -05:00

13 lines
473 B
PHP

<?php
/**
* If there is an uncaught exception,
* then print more of the backtrace than is done by default to stderr,
* then exit with a non-zero exit code to indicate failure.
*/
set_exception_handler(static function (Throwable $throwable) : void {
fwrite(STDERR, "Uncaught $throwable\n");
$version = defined('PSALM_VERSION') ? PSALM_VERSION : '(unknown version)';
fwrite(STDERR, "(Psalm $version crashed due to an uncaught Throwable)\n");
exit(1);
});