From 9d700a1fb0ae96cb2245d693791c130c755bbeeb Mon Sep 17 00:00:00 2001 From: SPT-dev Date: Thu, 2 Mar 2023 21:13:14 -0500 Subject: [PATCH] redirect bad routes to search page --- items/api/app/Exceptions/Handler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/items/api/app/Exceptions/Handler.php b/items/api/app/Exceptions/Handler.php index b375c61..8d36be8 100644 --- a/items/api/app/Exceptions/Handler.php +++ b/items/api/app/Exceptions/Handler.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Validation\ValidationException; use Laravel\Lumen\Exceptions\Handler as ExceptionHandler; use Symfony\Component\HttpKernel\Exception\HttpException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Throwable; class Handler extends ExceptionHandler @@ -49,6 +50,9 @@ class Handler extends ExceptionHandler */ public function render($request, Throwable $exception) { + if ($exception instanceof NotFoundHttpException) { + return redirect('/search'); + } return parent::render($request, $exception); } }