fix(capcut): 增强API错误响应详情

在API返回错误时,添加完整的响应数据切片到错误信息中,方便调试时定位问题。最多保留300字符的JSON数据。
This commit is contained in:
2026-05-06 23:33:33 +08:00
parent e2c1415156
commit 73b0860fe5
4 changed files with 24 additions and 33 deletions

View File

@@ -40,7 +40,7 @@ async function api(endpoint, data = {}, timeout = 60000) {
? await axios.get(url, { params: data, timeout })
: await axios.post(url, data, { timeout })
if (res.data.code !== undefined && res.data.code !== 0) {
throw new Error(`API [${endpoint}] 返回错误: ${res.data.message}`)
throw new Error(`API [${endpoint}] 返回错误: ${res.data.message} | detail: ${JSON.stringify(res.data).slice(0, 300)}`)
}
return res.data
} catch (err) {