Commit fbf60e54 authored by 刘小敏's avatar 刘小敏

3D试戴 调试8

parent 509a5110
...@@ -196,44 +196,8 @@ class Ai ...@@ -196,44 +196,8 @@ class Ai
'data' => $response_format == 'b64_json' ? $result['data'][0]['b64_json'] : $result['data'][0]['url'] 'data' => $response_format == 'b64_json' ? $result['data'][0]['b64_json'] : $result['data'][0]['url']
]; ];
} catch (HttpResponseException $e) {
$response = $e->getResponse();
$body = (string)$response->getData();
// 解析 JSON 获取详细错误
try {
$errorData = json_decode($body, true);
$fullMessage = '';
if (!empty($errorData['error'])) {
$error = $errorData['error'];
$fullMessage = $error['message'] ?? '';
// 如果有详细错误信息
if (!empty($error['details'])) {
$fullMessage .= "\nDetails: " . json_encode($error['details'], JSON_UNESCAPED_UNICODE);
}
}
// 如果解析失败,使用原始响应
if (empty($fullMessage)) {
$fullMessage = $body;
}
// 记录完整错误
format_log_error_custom_name($e, '[AI生成图片接口异常]', $body, 'gen_ai');
} catch (\Exception $jsonE) {
// 非JSON响应
format_log_error_custom_name($e, '[AI生成图片接口异常]', $jsonE->getMessage(), 'gen_ai');
}
// $message = $data ? ($data['msg'] ?? '') : $e->getMessage();
// format_log_error_custom_name($e, '[AI生成图片接口异常]'.' user_id:'. $userId , $message , 'gen_ai');
} catch (\Exception $e) { } catch (\Exception $e) {
$response = $e->getResponse(); format_log_error_custom_name($e, '[AI生成图片接口异常]','用户ID:'. $userId . ' response_format'. $response_format , 'gen_ai' );
$body = (string)$response->getData();
format_log_error_custom_name($e, '[AI生成图片接口异常]','用户ID:'. $userId . ' response_format'. $response_format.' 全错误信息:'.$body, 'gen_ai' );
return [ return [
'code' => 0 , 'code' => 0 ,
'msg' => '图片生成失败' 'msg' => '图片生成失败'
...@@ -313,12 +277,8 @@ class Ai ...@@ -313,12 +277,8 @@ class Ai
'data' => $result['id'] ?? '' 'data' => $result['id'] ?? ''
]; ];
} catch (HttpResponseException $e) {
$data = $e->getResponse()->getData();
$message = $data ? ($data['msg'] ?? '') : $e->getMessage();
format_log_error_custom_name($e, '[AI生成视频接口异常]','用户ID:'. $userId , $message , 'gen_ai');
} catch (\Exception $e) { } catch (\Exception $e) {
format_log_error_custom_name($e, '[AI生成视频接口异常]','用户ID:'. $userId , '' , 'gen_ai'); format_log_error_custom_name($e, '[AI生成视频接口异常] 用户ID:'. $userId , '', 'gen_ai' );
return [ return [
'code' => 0 , 'code' => 0 ,
'msg' => '视频生成失败' 'msg' => '视频生成失败'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment