MCPcopy Create free account
hub / github.com/Rfym21/Qwen2API / normalizeCliErrorDetails

Function normalizeCliErrorDetails

src/controllers/cli.chat.js:204–228  ·  view source on GitHub ↗

* 尝试解析 CLI 错误详情 * @param {*} data - 原始响应体 * @returns {Promise<*>} 可序列化的详情

(data)

Source from the content-addressed store, hash-verified

202 * @param {*} data - 原始响应体
203 * @returns {Promise<*>} 可序列化的详情
204 */
205async function normalizeCliErrorDetails(data) {
206 if (data && typeof data.on === 'function') {
207 const rawText = await readStreamBody(data)
208 if (!rawText) {
209 return ''
210 }
211
212 try {
213 return JSON.parse(rawText)
214 } catch (error) {
215 return rawText
216 }
217 }
218
219 if (Buffer.isBuffer(data)) {
220 const rawText = data.toString('utf8')
221 try {
222 return JSON.parse(rawText)
223 } catch (error) {
224 return rawText
225 }
226 }
227
228 return data
229}
230
231/**

Callers 2

buildCliAxiosErrorLogFunction · 0.85
handleCliChatCompletionFunction · 0.85

Calls 1

readStreamBodyFunction · 0.85

Tested by

no test coverage detected