Skip to content

Commit

Permalink
Allow Lumen to use custom error handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
cydrobolt committed Nov 7, 2015
1 parent 6086e32 commit 82be265
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Exception;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
Expand Down Expand Up @@ -39,6 +41,13 @@ public function report(Exception $e)
*/
public function render($request, Exception $e)
{
if ($e instanceof NotFoundHttpException){
return view('errors.404');
}
if ($e instanceof HttpException){
return view('errors.500');
}

return parent::render($request, $e);
}
}
2 changes: 1 addition & 1 deletion resources/views/errors/404.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
@section('content')
<h1>404</h1>
<p>This page could not be found.</p>
<h4>Are you sure you got the poles right?</h4>
<h4>Are you sure you correctly entered the URL?</h4>
@endsection
2 changes: 1 addition & 1 deletion resources/views/errors/500.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
@section('content')
<h1>500</h1>
<p>Oh dear. Something seems to have gone awry.</p>
<h4>Cold as an iceberg.</h4>
<h4>Please contact an administrator to report this issue.</h4>
@endsection

0 comments on commit 82be265

Please sign in to comment.