You can prevent the default Laravel view from showing if you return your own view from the exception handler.
You can change your App::error
handler to return a view:
App::error(function(Exception $exception)
{
Log::error($exception);
return Response::view('error.fatal', array(), 500);
});
You will want to also register other handlers below it for different kinds of exceptions. This is all explained in the Laravel documentation: http://laravel.com/docs/errors#handling-errors
A couple of recommendations for this use case though:
Don't run a composer update on production. You should commit your composer.lock
file and run composer install
instead to guarantee you get the same dependencies as you have tested on development (the lock file specifies exact commits to get from Github, rather than a version constaint which could result in you getting new code you didn't expect). Additionally, a composer install
is much faster since it's already resolved which dependencies to download and won't need to hit Packagist and do a lot of computation.
You should put your app into maintenance mode when deploying. You can run php artisan down
and any requests to your app will be handled by the App::down
handler in errors.php, so you could do something like:
App::down(function()
{
return Response::view('error.maintenance', [], 503);
});
Once you're done, you can bring the app back up with php artisan up
.
@maknz I did what you said and I am still getting the "Whoops, looks like something went wrong." page sometimes when the app gets down for some reason.
I just want to make a custom page/text for when it happens without changing /vendor/laravel/framework/src/Illuminate/Exception/resources/plain.html
file. Do you know how to do it?
Why not figure out what the issue is first, instead of trying to mask it? I'm sure the log files tell you more than "whoops, looks like something went wrong"?
You can prevent the default Laravel view from showing if you return your own view from the exception handler.
But, in my original post:
some types of exceptions supersede my exception handler and show a plain "Whoops, looks like something went wrong." page.
But it looks like artisan down
is the best work-around for the biggest of my specific issues.
ben-joostens said:
Why not figure out what the issue is first, instead of trying to mask it? I'm sure the log files tell you more than "whoops, looks like something went wrong"?
Because I have a live application with users who need to see a better message than "Whoops, looks like something went wrong."?
Hi, you need to put, depends on your development environment the value of the debug array item in true.
If you are using the local environment go to:
app/config/local/app.php
If you are using production environment go to:
app/config/app.php
The results should be:
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => true, //for production use false
If you are working with Laravel 5 version, you can find those files in the root config path.
Hope it helps you.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community