兼容修改

This commit is contained in:
张松
2025-08-15 17:47:00 +08:00
parent b86a663754
commit a677d253da

View File

@@ -14,6 +14,7 @@
namespace support;
use app\exception\MyBusinessException;
use app\exception\SysException;
use Throwable;
use Webman\Exception\ExceptionHandler;
@@ -34,13 +35,15 @@ class MyExceptionHandle extends ExceptionHandler implements ExceptionHandlerInte
public function report(Throwable $exception)
{
Log::error("捕获到全局异常,异常信息: ".$exception->getMessage());
Log::error($exception->getTraceAsString());
parent::report($exception);
}
public function render(Request $request, Throwable $exception): Response
{
if (!($exception instanceof MyBusinessException)) {
Log::error("捕获到全局异常,异常信息: ".$exception->getMessage());
Log::error($exception->getTraceAsString());
}
return json( [
'code' => -1,
'message' => $exception->getMessage(),