From 048f2f4eccc31b11ab815f94553d28ea61134fd7 Mon Sep 17 00:00:00 2001 From: liutk <961510893@qq.com> Date: Sat, 29 Jun 2024 19:09:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Exceptions/Handler.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index a1d85e6..4cf24a4 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -6,6 +6,7 @@ use Illuminate\Auth\AuthenticationException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; use Illuminate\Database\Eloquent\ModelNotFoundException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class Handler extends ExceptionHandler { @@ -39,6 +40,8 @@ class Handler extends ExceptionHandler if ($request->ajax() || $request->wantsJson()) { return response()->json(['data'=>null,'code'=>401 , 'message' => '无效凭证,请先登录' ], 401); } + }elseif ($e instanceof NotFoundHttpException) { + return response()->json(['data'=>null,'code'=>404 , 'message' => '页面不存在' ], 404); } } }