redirect bad routes to search page

This commit is contained in:
Rev 2021-12-22 16:18:25 +09:00
parent 53048e6147
commit 072f9659de

View File

@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler; use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable; use Throwable;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
@ -49,6 +50,9 @@ class Handler extends ExceptionHandler
*/ */
public function render($request, Throwable $exception) public function render($request, Throwable $exception)
{ {
if ($exception instanceof NotFoundHttpException) {
return redirect('/search');
}
return parent::render($request, $exception); return parent::render($request, $exception);
} }
} }