feat: 优化支付API请求错误日志,增强错误信息记录

This commit is contained in:
lingling 2025-03-21 20:49:51 +08:00
parent 7dee991b01
commit 472c7b940f
1 changed files with 5 additions and 5 deletions

View File

@ -112,15 +112,15 @@ class PaymentNew
return json_decode($responseBody); return json_decode($responseBody);
} catch (\GuzzleHttp\Exception\RequestException $e) { } catch (\GuzzleHttp\Exception\RequestException $e) {
Log::warning("请求支付api失未知失败:" . $e->getMessage()); // Log::warning("请求支付api失未知失败:" . $e->getMessage());
// 如果是 400 错误,可能有额外的请求错误信息 // 如果是 400 错误,可能有额外的请求错误信息
if ($e->hasResponse()) { if ($e->hasResponse()) {
$response = $e->getResponse(); $response = $e->getResponse();
$httpCode = $response->getStatusCode(); $httpCode = $response->getStatusCode();
if ($httpCode == 400) { $responseBody = $response->getBody()->getContents();
$responseBody = $response->getBody()->getContents(); Log::warning("请求支付api失败状态码: $httpCode ,响应体:" . $responseBody);
Log::warning("请求支付api失败状态码 400响应体" . $responseBody); }else{
} Log::warning("请求支付api未知失败并且没有返回头:" . $e->getMessage());
} }
return json_decode($responseBody); return json_decode($responseBody);
} }