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] Allow 500 custom error pages when not in debug mode #18481

Merged
merged 2 commits into from
Mar 25, 2017
Merged

[5.5] Allow 500 custom error pages when not in debug mode #18481

merged 2 commits into from
Mar 25, 2017

Conversation

laurencei
Copy link
Contributor

@laurencei laurencei commented Mar 24, 2017

As discussed with @taylorotwell in PR laravel/docs#3165

Currently, even with a views/errors/500.blade.php file, a non HttpException 500 error will still display a "whoops" page (with or without stack trace depending on env settings).

This PR changes behavior only when APP_DEBUG=false, to use a custom 500 error page if one is available. If no custom 500 page is available it will still display the same whoops error page (without a stack trace).

It solves issues such as #17586, #14137 & #10466

With APP_DEBUG=true (even with a custom 500 page):
debug_true

With APP_DEBUG=false and a no defined custom 500 error page:
debug_false1

With APP_DEBUG=false and a custom 500 error page:
debug_false2

@taylorotwell taylorotwell merged commit 82264fa into laravel:master Mar 25, 2017
@laurencei laurencei deleted the httpErrors branch March 25, 2017 15:10
@deleugpn
Copy link
Contributor

This is so good that is simple enough for us to override the prepareResponse method on the Exception\Handler.php while we wait for the official release of 5.5.

@Kyslik
Copy link
Contributor

Kyslik commented Mar 26, 2017

Is this a breaking change?

@laurencei
Copy link
Contributor Author

@Kyslik - no, it shouldnt be. It you dont have a custom 500 page in your app, it'll just display the normal 'whoops' page as it does now.

If you already have a 500 page in your app, then this just ensures it is displayed in all scenarios, not just some.

return $this->toIlluminateResponse($this->convertExceptionToResponse($e), $e);
}

if (! $this->isHttpException($e)) {
$e = new HttpException(500, $e->getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want this in 5.4

Anyone who uses PHPStorm and auto-import suggest importing HttpException (which might not exist)

import use Symfony\Component\HttpKernel\Exception\HttpException; instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants