How to change Whoops, looks like something went wrong error message in Laravel 4.2


'Whoops, looks like something went wrong', is the dafault error message from laravel, if you turn off the debugging option in laravel. You will not get this message when error happens and the debugging mode on laravel is set enable.

Okay i understand now, but what if i want to change this error message? is it possible to change this error message?

Yes, it's totally possible, you can change the 'Whoops, looks like something went wrong' error message into something else, you can even change the css style for this error message.

To change the error message 'Whoops, looks like something went wrong', you need to edit file global.php, this file is located inside app/start/ folder.
app/start/global.php
Take a look at the 'App::error(function(Exception $exception, $code)' part, change the codes into like this:
App::error(function(Exception $exception, $code)
{
 Log::error($exception);
 if (!Config::get('app.debug')) {
  return 'This is the new error message';
 }
});

Now you should have different error message, no more 'Whoops, looks like something went wrong', instead you will get 'This is the new error message' as the default error message.


If you want to take it to another level, you can create a dedicated view contains your own error message and the styling (css), and then change the code to like this:
App::error(function(Exception $exception, $code)
{
 Log::error($exception);
 if (!Config::get('app.debug')) {
  return View::make('errors.general');
 }
});
The code above assuming you have laravel view called 'errors.general'.




EmoticonEmoticon