From 7abf180f3b5f1763585b116d52894ec529db9990 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Sat, 20 Apr 2024 10:40:18 +0800 Subject: [PATCH] NotFoundHttpException --- app/Exceptions/Handler.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 6bfc524..51c87f4 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -4,9 +4,10 @@ namespace App\Exceptions; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; -use Illuminate\Http\{Request}; +use Illuminate\Http\{Request, Response}; use Illuminate\Validation\ValidationException; use Slowlyo\OwlAdmin\Exceptions\AdminException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class Handler extends ExceptionHandler { @@ -34,6 +35,10 @@ class Handler extends ExceptionHandler $this->renderable(function (RuntimeException $e, Request $request) { return response(['code' => $e->getCode(), 'message' => $e->getMessage()], $e->getHttpStatusCode()); }); + + $this->renderable(function (NotFoundHttpException $e, Request $request) { + return response(['code' => Response::HTTP_NOT_FOUND, 'message' => $e->getMessage()], Response::HTTP_NOT_FOUND); + }); } protected function invalidJson($request, ValidationException $exception)