diff --git a/app/ExceptionHandler.php b/app/ExceptionHandler.php index 483b9d6b..0ba7badc 100644 --- a/app/ExceptionHandler.php +++ b/app/ExceptionHandler.php @@ -7,6 +7,7 @@ use Next\VarDumper\Dumper; use Next\VarDumper\DumperHandler; use support\exception\BusinessException; use support\exception\Handler; +use support\Log; use Throwable; use Webman\Http\Request; use Webman\Http\Response; @@ -22,6 +23,7 @@ class ExceptionHandler extends Handler return \response(self::convertToHtml($exception)); }elseif ($exception instanceof BusinessException) { if ($request->expectsJson()) { + Log::error('BusinessException:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]); return json(['code' => 0, 'msg' => $exception->getMessage(),'show'=>1]); } return response($exception->getMessage()); @@ -35,9 +37,12 @@ class ExceptionHandler extends Handler $error['file'] = $exception->getFile(); $error['line'] = $exception->getLine(); } + Log::error('Exception:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]); return response(json_encode($error, JSON_UNESCAPED_UNICODE)); } // 非json请求则返回一个页面 + Log::error('other:',['msg'=>$exception->getMessage(),'file'=>$exception->getFile(),'line'=>$exception->getLine()]); + return new Response(200, [], 'msg:'.$exception->getMessage().'。line:'.$exception->getLine().'。file:'.$exception->getFile()); } } diff --git a/app/MyBusinessException.php b/app/MyBusinessException.php deleted file mode 100644 index bebfa4e0..00000000 --- a/app/MyBusinessException.php +++ /dev/null @@ -1,20 +0,0 @@ -expectsJson()) { - return json(['code' => $this->getCode() ?: 500, 'msg' => $this->getMessage(),'show'=>1]); - } - // 非json请求则返回一个页面 - return new Response(200, [], $this->getMessage()); - } -} \ No newline at end of file diff --git a/app/admin/validate/LoginValidate.php b/app/admin/validate/LoginValidate.php index 02dac88a..5b39f448 100644 --- a/app/admin/validate/LoginValidate.php +++ b/app/admin/validate/LoginValidate.php @@ -9,7 +9,6 @@ use app\common\enum\AdminTerminalEnum; use app\common\model\auth\Admin; use app\common\service\ConfigService; use app\common\validate\BaseValidate; -use app\MyBusinessException; use support\exception\BusinessException; use Webman\Config; diff --git a/app/api/lists/store/SystemStoreLists.php b/app/api/lists/store/SystemStoreLists.php index a45511f3..b48eaae6 100644 --- a/app/api/lists/store/SystemStoreLists.php +++ b/app/api/lists/store/SystemStoreLists.php @@ -9,8 +9,7 @@ use app\common\model\order\Cart; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\system_store\SystemStore; use app\common\lists\ListsSearchInterface; -use app\MyBusinessException; -use think\Exception; + /** diff --git a/app/store/logic/LoginLogic.php b/app/store/logic/LoginLogic.php index 453a991c..adec25c4 100644 --- a/app/store/logic/LoginLogic.php +++ b/app/store/logic/LoginLogic.php @@ -20,8 +20,6 @@ use app\common\model\system_store\SystemStoreStaff; use app\store\service\AdminTokenService; use app\common\model\auth\AdminRole; use app\common\service\FileService; -use app\MyBusinessException; -use think\facade\Db; use Webman\Config; /** diff --git a/app/store/logic/store_branch_product/StoreBranchProductLogic.php b/app/store/logic/store_branch_product/StoreBranchProductLogic.php index 7837ac1b..9b1bce6c 100644 --- a/app/store/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/store/logic/store_branch_product/StoreBranchProductLogic.php @@ -9,7 +9,6 @@ use app\common\model\store_product\StoreProduct; use app\common\logic\BaseLogic; use app\common\model\store_category\StoreCategory; use app\common\model\store_product_attr_value\StoreProductAttrValue; -use app\MyBusinessException; use support\exception\BusinessException; use think\facade\Db;