feat: add custom 404 error page and handle exceptions for not found errors
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class Handler extends ExceptionHandler {
|
||||
|
||||
@@ -42,6 +44,11 @@ class Handler extends ExceptionHandler {
|
||||
if (!$e instanceof Exception) {
|
||||
$e = new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
|
||||
}
|
||||
|
||||
if ($e instanceof NotFoundHttpException || $e instanceof ModelNotFoundException) {
|
||||
return response()->view('errors.404', [], 404);
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user