This is the plain exception handler;, already available in app/start/global.php
by default, modify it as given below (Btw, Whoops! PHP Errors only for Cool Kids):
App::error(function(Exception $exception)
{
Log::error($exception);Log::error($exception->getMessage());
return View::make('errors.index')->with('exception', $exception);
});
Create a view view/errors/index.blade.php
@extends('layouts.master')
@section('content')
<div class="page-header">
<h1>Oops!</h1>
</div>
<div class='well'>ERROR: {{ $exception->getMessage() }}</div>
@stop
Also make 'debug' => false
in your app/config/app.php
file:
/*
|--------------------------------------------------------------------------
| 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' => false,
You have following methods to use in $exception
object:
array (size=10)
//0 => string '__construct' (length=11)
1 => string 'getSeverity' (length=11)
2 => string 'getMessage' (length=10)
3 => string 'getCode' (length=7)
4 => string 'getFile' (length=7)
5 => string 'getLine' (length=7)
6 => string 'getTrace' (length=8)
7 => string 'getPrevious' (length=11)
8 => string 'getTraceAsString' (length=16)
//9 => string '__toString' (length=10)
If you leave 'debug' => true,
then still your exception handler will work but in some cases it may display whoops
when the exception is not caught in you handler but in another specific handler before your generic Exception
handler.
Also remember that, Exception
class is the most generic exception type, if you have other more specific exception handlers defined after that then it'll not get triggered if any response returned from that specific handler.