MCPcopy Create free account
hub / github.com/aptdnfapt/qwen-code-oai-proxy / extractRealErrorMessage

Function extractRealErrorMessage

src/server/proxy-controller.ts:106–122  ·  view source on GitHub ↗

* Extract the real error message from the upstream response. * Axios wraps the Qwen error in error.message = "Request failed with status code 429" * The actual Qwen message lives in error.response.data.error.message or upstreamErrorDetails.

(error: any)

Source from the content-addressed store, hash-verified

104 * The actual Qwen message lives in error.response.data.error.message or upstreamErrorDetails.
105 */
106function extractRealErrorMessage(error: any): string {
107 // Try upstream error details attached by attachUpstreamErrorDetails()
108 const raw = error?.upstreamErrorDetails?.rawBody;
109 if (typeof raw === "string") {
110 try {
111 const parsed = JSON.parse(raw);
112 if (parsed?.error?.message) return parsed.error.message;
113 } catch { /* not JSON */ }
114 }
115
116 // Try Axios response body
117 const responseData = error?.response?.data;
118 if (responseData?.error?.message) return responseData.error.message;
119
120 // Fallback to the error message itself
121 return error?.message || "Unknown error";
122}
123
124export class QwenOpenAIProxy {
125 qwenAPI: any;

Callers 7

handleChatCompletionMethod · 0.85
handleModelsMethod · 0.85
handleAuthInitiateMethod · 0.85
handleAuthPollMethod · 0.85
handleWebSearchMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected