Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Fix Whoops exception rendering #19471

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use Symfony as a last resort exception handler
This prevents white screens if something goes wrong with Whoops setup.
  • Loading branch information
thecrypticace committed Jun 4, 2017
commit f2cd3c3396590944db2d789bf496f875a2bff0aa
24 changes: 14 additions & 10 deletions src/Illuminate/Foundation/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,19 @@ protected function convertExceptionToResponse(Exception $e)
$headers = $this->isHttpException($e) ? $e->getHeaders() : [];
$statusCode = $this->isHttpException($e) ? $e->getStatusCode() : 500;

if (config('app.debug')) {
return SymfonyResponse::create(
$this->renderExceptionWithWhoops($e), $statusCode, $headers
);
} else {
return SymfonyResponse::create(
$this->renderExceptionWithSymfony($e), $statusCode, $headers
);
$showStackTraces = config('app.debug');

try {
$content = $showStackTraces
? $this->renderExceptionWithWhoops($e)
: $this->renderExceptionWithSymfony($e, $showStackTraces);
} finally {
$content = $content ?? $this->renderExceptionWithSymfony($e, $showStackTraces);
}

return SymfonyResponse::create(
$content, $statusCode, $headers
);
}

/**
Expand All @@ -282,11 +286,11 @@ protected function renderExceptionWithWhoops(Exception $e)
* @param \Exception $e
* @return string
*/
protected function renderExceptionWithSymfony(Exception $e)
protected function renderExceptionWithSymfony(Exception $e, $showStackTraces)
{
$e = FlattenException::create($e);

return (new SymfonyExceptionHandler(false))->getHtml($e);
return (new SymfonyExceptionHandler($showStackTraces))->getHtml($e);
}

/**
Expand Down