兼容修改
This commit is contained in:
@@ -41,15 +41,20 @@ class MyExceptionHandle extends ExceptionHandler implements ExceptionHandlerInte
|
||||
public function render(Request $request, Throwable $exception): Response
|
||||
{
|
||||
if (!($exception instanceof MyBusinessException)) {
|
||||
Log::error("捕获到全局异常,异常信息: ".$exception->getMessage());
|
||||
Log::error("捕获到全局异常,异常类,".$exception::class." 异常信息: ".$exception->getMessage());
|
||||
Log::error($exception->getTraceAsString());
|
||||
}
|
||||
return json( [
|
||||
'code' => -1,
|
||||
'message' => $exception->getMessage(),
|
||||
'time' => time(),
|
||||
'data' => [],
|
||||
]);
|
||||
}
|
||||
|
||||
// 非json请求则返回一个页面
|
||||
return new Response(200, [], $exception->getMessage());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user