Browse Source

接口报错

lizhen_gitee 6 months ago
parent
commit
8d97adb608
1 changed files with 2 additions and 1 deletions
  1. 2 1
      application/api/library/ExceptionHandle.php

+ 2 - 1
application/api/library/ExceptionHandle.php

@@ -16,7 +16,7 @@ class ExceptionHandle extends Handle
         // 在生产环境下返回code信息
         if (!\think\Config::get('app_debug')) {
             $statuscode = $code = 500;
-            $msg = 'An error occurred';
+            $msg = $e->getMessage();
             // 验证异常
             if ($e instanceof \think\exception\ValidateException) {
                 $code = 0;
@@ -26,6 +26,7 @@ class ExceptionHandle extends Handle
             // Http异常
             if ($e instanceof \think\exception\HttpException) {
                 $statuscode = $code = $e->getStatusCode();
+                $msg = $e->getMessage();
             }
             return json(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => null], $statuscode);
         }