diff --git a/crmeb/app/adminapi/AdminApiExceptionHandle.php b/crmeb/app/adminapi/AdminApiExceptionHandle.php index be265fe5d..1927511f7 100644 --- a/crmeb/app/adminapi/AdminApiExceptionHandle.php +++ b/crmeb/app/adminapi/AdminApiExceptionHandle.php @@ -78,27 +78,18 @@ class AdminApiExceptionHandle extends Handle public function render($request, Throwable $e): Response { $massageData = Env::get('app_debug', false) ? [ + 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTrace(), 'previous' => $e->getPrevious(), ] : []; + $message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了'; // 添加自定义异常处理机制 - if ($e instanceof DbException) { - return app('json')->fail(100102, $massageData); - } elseif ($e instanceof ValidateException) { - return app('json')->fail($e->getMessage(), $massageData); - } elseif ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) { - return app('json')->make($e->getCode() ?: 400, $e->getMessage(), $massageData); + if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) { + return app('json')->make($e->getCode() ?: 400, $message, $massageData); } else { - return app('json')->fail('很抱歉!系统开小差了', Env::get('app_debug', false) ? [ - 'message' => $e->getMessage(), - 'file' => $e->getFile(), - 'code' => $e->getCode(), - 'line' => $e->getLine(), - 'trace' => $e->getTrace(), - 'previous' => $e->getPrevious(), - ] : []); + return app('json')->fail($message, $massageData); } } diff --git a/crmeb/app/api/ApiExceptionHandle.php b/crmeb/app/api/ApiExceptionHandle.php index 1a775bdbc..f4b868e87 100644 --- a/crmeb/app/api/ApiExceptionHandle.php +++ b/crmeb/app/api/ApiExceptionHandle.php @@ -78,27 +78,18 @@ class ApiExceptionHandle extends Handle public function render($request, Throwable $e): Response { $massageData = Env::get('app_debug', false) ? [ + 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTrace(), 'previous' => $e->getPrevious(), ] : []; + $message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了'; // 添加自定义异常处理机制 - if ($e instanceof DbException) { - return app('json')->fail(100102, $massageData); - } elseif ($e instanceof ValidateException) { - return app('json')->fail($e->getMessage(), $massageData); - } elseif ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) { - return app('json')->make($e->getCode() ?: 400, $e->getMessage(), $massageData); + if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) { + return app('json')->make($e->getCode() ?: 400, $message, $massageData); } else { - return app('json')->fail('很抱歉!系统开小差了', Env::get('app_debug', false) ? [ - 'message' => $e->getMessage(), - 'file' => $e->getFile(), - 'code' => $e->getCode(), - 'line' => $e->getLine(), - 'trace' => $e->getTrace(), - 'previous' => $e->getPrevious(), - ] : []); + return app('json')->fail($message, $massageData); } } diff --git a/crmeb/app/kefuapi/KefuApiExceptionHandle.php b/crmeb/app/kefuapi/KefuApiExceptionHandle.php index 2b44c7bc9..047e4e4ca 100644 --- a/crmeb/app/kefuapi/KefuApiExceptionHandle.php +++ b/crmeb/app/kefuapi/KefuApiExceptionHandle.php @@ -78,27 +78,18 @@ class KefuApiExceptionHandle extends Handle public function render($request, Throwable $e): Response { $massageData = Env::get('app_debug', false) ? [ + 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTrace(), 'previous' => $e->getPrevious(), ] : []; + $message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了'; // 添加自定义异常处理机制 - if ($e instanceof DbException) { - return app('json')->fail(100102, $massageData); - } elseif ($e instanceof ValidateException) { - return app('json')->fail($e->getMessage(), $massageData); - } elseif ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) { - return app('json')->make($e->getCode() ?: 400, $e->getMessage(), $massageData); + if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) { + return app('json')->make($e->getCode() ?: 400, $message, $massageData); } else { - return app('json')->fail('很抱歉!系统开小差了', Env::get('app_debug', false) ? [ - 'message' => $e->getMessage(), - 'file' => $e->getFile(), - 'code' => $e->getCode(), - 'line' => $e->getLine(), - 'trace' => $e->getTrace(), - 'previous' => $e->getPrevious(), - ] : []); + return app('json')->fail($message, $massageData); } } } diff --git a/crmeb/app/outapi/OutApiExceptionHandle.php b/crmeb/app/outapi/OutApiExceptionHandle.php index 848c2b524..934247623 100644 --- a/crmeb/app/outapi/OutApiExceptionHandle.php +++ b/crmeb/app/outapi/OutApiExceptionHandle.php @@ -78,27 +78,18 @@ class OutApiExceptionHandle extends Handle public function render($request, Throwable $e): Response { $massageData = Env::get('app_debug', false) ? [ + 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTrace(), 'previous' => $e->getPrevious(), ] : []; + $message = Env::get('app_debug', false) ? '接口报错:' . $e->getMessage() : '很抱歉,系统开小差了'; // 添加自定义异常处理机制 - if ($e instanceof DbException) { - return app('json')->fail(100102, $massageData); - } elseif ($e instanceof ValidateException) { - return app('json')->fail($e->getMessage(), $massageData); - } elseif ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) { - return app('json')->make($e->getCode() ?: 400, $e->getMessage(), $massageData); + if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException) { + return app('json')->make($e->getCode() ?: 400, $message, $massageData); } else { - return app('json')->fail('很抱歉!系统开小差了', Env::get('app_debug', false) ? [ - 'message' => $e->getMessage(), - 'file' => $e->getFile(), - 'code' => $e->getCode(), - 'line' => $e->getLine(), - 'trace' => $e->getTrace(), - 'previous' => $e->getPrevious(), - ] : []); + return app('json')->fail($message, $massageData); } }