* 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)
| 104 | * The actual Qwen message lives in error.response.data.error.message or upstreamErrorDetails. |
| 105 | */ |
| 106 | function 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 | |
| 124 | export class QwenOpenAIProxy { |
| 125 | qwenAPI: any; |
no outgoing calls
no test coverage detected