Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7b9b1b9

Browse filesBrowse files
committed
Redesign the Debug error page in prod
1 parent 3d8490e commit 7b9b1b9
Copy full SHA for 7b9b1b9

File tree

Expand file treeCollapse file tree

1 file changed

+52
-38
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+52
-38
lines changed

‎src/Symfony/Component/Debug/ExceptionHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ExceptionHandler.php
+52-38Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -208,48 +208,54 @@ public function getContent(FlattenException $exception)
208208
$title = 'Whoops, looks like something went wrong.';
209209
}
210210

211+
if (!$this->debug) {
212+
return <<<EOF
213+
<div class="container">
214+
<h1>$title</h1>
215+
</div>
216+
EOF;
217+
}
218+
211219
$content = '';
212-
if ($this->debug) {
213-
try {
214-
$count = count($exception->getAllPrevious());
215-
$total = $count + 1;
216-
foreach ($exception->toArray() as $position => $e) {
217-
$ind = $count - $position + 1;
218-
$class = $this->formatClass($e['class']);
219-
$message = nl2br($this->escapeHtml($e['message']));
220-
$content .= sprintf(<<<'EOF'
221-
<div class="trace trace-as-html">
222-
<table class="trace-details">
223-
<thead class="trace-head"><tr><th>
224-
<h3 class="trace-class">
225-
<span class="text-muted">(%d/%d)</span>
226-
<span class="exception_title">%s</span>
227-
</h3>
228-
<p class="break-long-words trace-message">%s</p>
229-
</th></tr></thead>
230-
<tbody>
220+
try {
221+
$count = count($exception->getAllPrevious());
222+
$total = $count + 1;
223+
foreach ($exception->toArray() as $position => $e) {
224+
$ind = $count - $position + 1;
225+
$class = $this->formatClass($e['class']);
226+
$message = nl2br($this->escapeHtml($e['message']));
227+
$content .= sprintf(<<<'EOF'
228+
<div class="trace trace-as-html">
229+
<table class="trace-details">
230+
<thead class="trace-head"><tr><th>
231+
<h3 class="trace-class">
232+
<span class="text-muted">(%d/%d)</span>
233+
<span class="exception_title">%s</span>
234+
</h3>
235+
<p class="break-long-words trace-message">%s</p>
236+
</th></tr></thead>
237+
<tbody>
231238
EOF
232-
, $ind, $total, $class, $message);
233-
foreach ($e['trace'] as $trace) {
234-
$content .= '<tr><td>';
235-
if ($trace['function']) {
236-
$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']));
237-
}
238-
if (isset($trace['file']) && isset($trace['line'])) {
239-
$content .= $this->formatPath($trace['file'], $trace['line']);
240-
}
241-
$content .= "</td></tr>\n";
239+
, $ind, $total, $class, $message);
240+
foreach ($e['trace'] as $trace) {
241+
$content .= '<tr><td>';
242+
if ($trace['function']) {
243+
$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']));
242244
}
243-
244-
$content .= "</tbody>\n</table>\n</div>\n";
245-
}
246-
} catch (\Exception $e) {
247-
// something nasty happened and we cannot throw an exception anymore
248-
if ($this->debug) {
249-
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $this->escapeHtml($e->getMessage()));
250-
} else {
251-
$title = 'Whoops, looks like something went wrong.';
245+
if (isset($trace['file']) && isset($trace['line'])) {
246+
$content .= $this->formatPath($trace['file'], $trace['line']);
247+
}
248+
$content .= "</td></tr>\n";
252249
}
250+
251+
$content .= "</tbody>\n</table>\n</div>\n";
252+
}
253+
} catch (\Exception $e) {
254+
// something nasty happened and we cannot throw an exception anymore
255+
if ($this->debug) {
256+
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $this->escapeHtml($e->getMessage()));
257+
} else {
258+
$title = 'Whoops, looks like something went wrong.';
253259
}
254260
}
255261

@@ -278,6 +284,14 @@ public function getContent(FlattenException $exception)
278284
*/
279285
public function getStylesheet(FlattenException $exception)
280286
{
287+
if (!$this->debug) {
288+
return <<<'EOF'
289+
body { background-color: #fff; color: #222; font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; margin: 0; }
290+
.container { margin: 30px; max-width: 600px; }
291+
h1 { color: #dc3545; font-size: 24px; }
292+
EOF;
293+
}
294+
281295
return <<<'EOF'
282296
body { background-color: #F9F9F9; color: #222; font: 14px/1.4 Helvetica, Arial, sans-serif; margin: 0; padding-bottom: 45px; }
283297

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.