Skip to content
Permalink
Browse files

Debugger::exceptionHandler() log exceptions even if it is not called …

…for the first time
  • Loading branch information
dg committed Nov 28, 2019
1 parent bcbdaee commit b5a068101c0e092a9bfbfb082b444828d8d6c1b6
Showing with 7 additions and 7 deletions.
  1. +7 −7 src/Tracy/Debugger/Debugger.php
@@ -289,9 +289,7 @@ public static function shutdownHandler(): void
*/
public static function exceptionHandler(\Throwable $exception): void
{
if (self::$reserved === null) {
return;
}
$firstTime = (bool) self::$reserved;
self::$reserved = null;
if (!headers_sent()) {
@@ -310,15 +308,17 @@ public static function exceptionHandler(\Throwable $exception): void
} catch (\Throwable $e) {
}
if (Helpers::isHtmlMode()) {
if (!$firstTime) {
// nothing
} elseif (Helpers::isHtmlMode()) {
$logged = empty($e);
require self::$errorTemplate ?: __DIR__ . '/assets/error.500.phtml';
} elseif (PHP_SAPI === 'cli') {
fwrite(STDERR, 'ERROR: application encountered an error and can not continue. '
. (isset($e) ? "Unable to log error.\n" : "Error was logged.\n"));
}
} elseif (Helpers::isHtmlMode() || Helpers::isAjax()) {
} elseif ($firstTime && Helpers::isHtmlMode() || Helpers::isAjax()) {
self::getBlueScreen()->render($exception);
if (self::$showBar) {
self::getBar()->render();
@@ -329,7 +329,7 @@ public static function exceptionHandler(\Throwable $exception): void
try {
$file = self::log($exception, self::EXCEPTION);
if ($file && !headers_sent()) {
header("X-Tracy-Error-Log: $file");
header("X-Tracy-Error-Log: $file", false);
}
echo "$exception\n" . ($file ? "(stored in $file)\n" : '');
if ($file && self::$browser) {
@@ -341,7 +341,7 @@ public static function exceptionHandler(\Throwable $exception): void
}
try {
foreach (self::$onFatalError as $handler) {
foreach ($firstTime ? self::$onFatalError : [] as $handler) {
$handler($exception);
}
} catch (\Throwable $e) {

0 comments on commit b5a0681

Please sign in to comment.
You can’t perform that action at this time.