From 82be265af86b6a6f1769fc8a00f1bdda8fa4ee7e Mon Sep 17 00:00:00 2001 From: Chaoyi Zha Date: Fri, 6 Nov 2015 21:56:09 -0500 Subject: [PATCH] Allow Lumen to use custom error handlers --- app/Exceptions/Handler.php | 9 +++++++++ resources/views/errors/404.blade.php | 2 +- resources/views/errors/500.blade.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8d0b13e..37c3947 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -4,6 +4,8 @@ namespace App\Exceptions; 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 @@ -39,6 +41,13 @@ class Handler extends ExceptionHandler */ 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); } } diff --git a/resources/views/errors/404.blade.php b/resources/views/errors/404.blade.php index da589d0..572727c 100644 --- a/resources/views/errors/404.blade.php +++ b/resources/views/errors/404.blade.php @@ -3,5 +3,5 @@ @section('content')

404

This page could not be found.

-

Are you sure you got the poles right?

+

Are you sure you correctly entered the URL?

@endsection diff --git a/resources/views/errors/500.blade.php b/resources/views/errors/500.blade.php index a0dd470..e611933 100644 --- a/resources/views/errors/500.blade.php +++ b/resources/views/errors/500.blade.php @@ -3,5 +3,5 @@ @section('content')

500

Oh dear. Something seems to have gone awry.

-

Cold as an iceberg.

+

Please contact an administrator to report this issue.

@endsection