MCPcopy Create free account
hub / github.com/langgenius/dify / classifyResponse

Function classifyResponse

cli/src/http/error-mapper.ts:79–101  ·  view source on GitHub ↗
(request: Request, response: Response)

Source from the content-addressed store, hash-verified

77}
78
79export async function classifyResponse(request: Request, response: Response): Promise<HttpClientError> {
80 let raw = ''
81 try {
82 raw = await response.clone().text()
83 }
84 catch {
85 // ignore read errors; raw stays ''
86 }
87
88 const serverError = parseServerError(raw)
89 const status = response.status
90 const c = statusClass(status)
91 return new HttpClientError({
92 code: c.code,
93 message: serverError?.message ?? c.fallbackMessage(status),
94 hint: c.hint,
95 httpStatus: status,
96 method: request.method,
97 url: redactBearer(response.url || request.url),
98 rawResponse: c.includeRaw && raw !== '' ? raw : undefined,
99 serverError,
100 })
101}
102
103export function classifyTransportError(err: unknown): BaseError {
104 if (err instanceof BaseError) {

Callers 4

classifiedFunction · 0.90
createOpenApiClientFunction · 0.85
executeFunction · 0.85

Calls 5

redactBearerFunction · 0.90
parseServerErrorFunction · 0.85
statusClassFunction · 0.85
textMethod · 0.45
cloneMethod · 0.45

Tested by 1

classifiedFunction · 0.72