Skip to content

Commit

Permalink
Debugger: improved way how Tracy informs whether error was logged
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 30, 2014
1 parent 658f509 commit 0ee5643
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Tracy/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,18 +405,18 @@ public static function _exceptionHandler(\Exception $exception, $exit = TRUE)
}
}

$logMsg = 'Unable to log error. Check if directory is writable and path is absolute.';
if (self::$productionMode) {
try {
self::log($exception, self::EXCEPTION);
} catch (\Exception $e) {
}

$error = isset($e) ? $logMsg : NULL;
if (self::isHtmlMode()) {
$logged = empty($e);
require __DIR__ . '/templates/error.phtml';
} elseif (PHP_SAPI === 'cli') {
fwrite(STDERR, "ERROR: application encountered an error and can not continue.\n$error\n");
fwrite(STDERR, 'ERROR: application encountered an error and can not continue. '
. (isset($e) ? "Unable to log error.\n" : "Error was logged.\n"));
}

} elseif (!connection_aborted() && self::isHtmlMode()) {
Expand All @@ -434,7 +434,7 @@ public static function _exceptionHandler(\Exception $exception, $exit = TRUE)
exec(self::$browser . ' ' . escapeshellarg($file));
}
} catch (\Exception $e) {
echo "$exception\n$logMsg {$e->getMessage()}\n";
echo "$exception\nUnable to log error: {$e->getMessage()}\n";
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Tracy/templates/error.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Default error page.
* @param string $error
* @param bool $logged
*/

namespace Tracy;
Expand All @@ -27,5 +27,5 @@ namespace Tracy;
<p>We're sorry! The server encountered an internal error and
was unable to complete your request. Please try again later.</p>

<p><small>error 500<?php if (!empty($error)) echo "<br>Tracy says: ", htmlspecialchars($error) ?></small></p>
<p><small>error 500<?php if (!$logged): ?><br>Tracy is unable to log error.<?php endif ?></small></p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Test: Tracy\Debugger::_exceptionHandler() error.
* @exitCode 254
* @httpCode 500
* @outputMatch exception 'Exception' in%A%Unable to log error.%A%
* @outputMatch exception 'Exception' in%A%Unable to log error: %A%
*/

use Tracy\Debugger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Test: Tracy\Debugger::_exceptionHandler() error.
* @exitCode 254
* @httpCode 500
* @outputMatch %A%<title>Server Error</title>%A%Unable to log error%A%
* @outputMatch %A%<title>Server Error</title>%A%Tracy is unable to log error%A%
*/

use Tracy\Debugger;
Expand Down

0 comments on commit 0ee5643

Please sign in to comment.