Redesign the Debug error page in prod
This commit is contained in:
parent
3d8490e59c
commit
7b9b1b9022
@ -208,48 +208,54 @@ class ExceptionHandler
|
|||||||
$title = 'Whoops, looks like something went wrong.';
|
$title = 'Whoops, looks like something went wrong.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = '';
|
if (!$this->debug) {
|
||||||
if ($this->debug) {
|
return <<<EOF
|
||||||
try {
|
<div class="container">
|
||||||
$count = count($exception->getAllPrevious());
|
<h1>$title</h1>
|
||||||
$total = $count + 1;
|
</div>
|
||||||
foreach ($exception->toArray() as $position => $e) {
|
EOF;
|
||||||
$ind = $count - $position + 1;
|
}
|
||||||
$class = $this->formatClass($e['class']);
|
|
||||||
$message = nl2br($this->escapeHtml($e['message']));
|
|
||||||
$content .= sprintf(<<<'EOF'
|
|
||||||
<div class="trace trace-as-html">
|
|
||||||
<table class="trace-details">
|
|
||||||
<thead class="trace-head"><tr><th>
|
|
||||||
<h3 class="trace-class">
|
|
||||||
<span class="text-muted">(%d/%d)</span>
|
|
||||||
<span class="exception_title">%s</span>
|
|
||||||
</h3>
|
|
||||||
<p class="break-long-words trace-message">%s</p>
|
|
||||||
</th></tr></thead>
|
|
||||||
<tbody>
|
|
||||||
EOF
|
|
||||||
, $ind, $total, $class, $message);
|
|
||||||
foreach ($e['trace'] as $trace) {
|
|
||||||
$content .= '<tr><td>';
|
|
||||||
if ($trace['function']) {
|
|
||||||
$content .= sprintf('at <span class="trace-class">%s</span><span class="trace-type">%s</span><span class="trace-method">%s</span>(<span class="trace-arguments">%s</span>)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
|
|
||||||
}
|
|
||||||
if (isset($trace['file']) && isset($trace['line'])) {
|
|
||||||
$content .= $this->formatPath($trace['file'], $trace['line']);
|
|
||||||
}
|
|
||||||
$content .= "</td></tr>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$content .= "</tbody>\n</table>\n</div>\n";
|
$content = '';
|
||||||
}
|
try {
|
||||||
} catch (\Exception $e) {
|
$count = count($exception->getAllPrevious());
|
||||||
// something nasty happened and we cannot throw an exception anymore
|
$total = $count + 1;
|
||||||
if ($this->debug) {
|
foreach ($exception->toArray() as $position => $e) {
|
||||||
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $this->escapeHtml($e->getMessage()));
|
$ind = $count - $position + 1;
|
||||||
} else {
|
$class = $this->formatClass($e['class']);
|
||||||
$title = 'Whoops, looks like something went wrong.';
|
$message = nl2br($this->escapeHtml($e['message']));
|
||||||
|
$content .= sprintf(<<<'EOF'
|
||||||
|
<div class="trace trace-as-html">
|
||||||
|
<table class="trace-details">
|
||||||
|
<thead class="trace-head"><tr><th>
|
||||||
|
<h3 class="trace-class">
|
||||||
|
<span class="text-muted">(%d/%d)</span>
|
||||||
|
<span class="exception_title">%s</span>
|
||||||
|
</h3>
|
||||||
|
<p class="break-long-words trace-message">%s</p>
|
||||||
|
</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
EOF
|
||||||
|
, $ind, $total, $class, $message);
|
||||||
|
foreach ($e['trace'] as $trace) {
|
||||||
|
$content .= '<tr><td>';
|
||||||
|
if ($trace['function']) {
|
||||||
|
$content .= sprintf('at <span class="trace-class">%s</span><span class="trace-type">%s</span><span class="trace-method">%s</span>(<span class="trace-arguments">%s</span>)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
|
||||||
|
}
|
||||||
|
if (isset($trace['file']) && isset($trace['line'])) {
|
||||||
|
$content .= $this->formatPath($trace['file'], $trace['line']);
|
||||||
|
}
|
||||||
|
$content .= "</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$content .= "</tbody>\n</table>\n</div>\n";
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// something nasty happened and we cannot throw an exception anymore
|
||||||
|
if ($this->debug) {
|
||||||
|
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $this->escapeHtml($e->getMessage()));
|
||||||
|
} else {
|
||||||
|
$title = 'Whoops, looks like something went wrong.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,6 +284,14 @@ EOF;
|
|||||||
*/
|
*/
|
||||||
public function getStylesheet(FlattenException $exception)
|
public function getStylesheet(FlattenException $exception)
|
||||||
{
|
{
|
||||||
|
if (!$this->debug) {
|
||||||
|
return <<<'EOF'
|
||||||
|
body { background-color: #fff; color: #222; font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; margin: 0; }
|
||||||
|
.container { margin: 30px; max-width: 600px; }
|
||||||
|
h1 { color: #dc3545; font-size: 24px; }
|
||||||
|
EOF;
|
||||||
|
}
|
||||||
|
|
||||||
return <<<'EOF'
|
return <<<'EOF'
|
||||||
body { background-color: #F9F9F9; color: #222; font: 14px/1.4 Helvetica, Arial, sans-serif; margin: 0; padding-bottom: 45px; }
|
body { background-color: #F9F9F9; color: #222; font: 14px/1.4 Helvetica, Arial, sans-serif; margin: 0; padding-bottom: 45px; }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user