mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 17:27:54 +00:00
fix: remove direct gaxios dependency (#4289)
This commit is contained in:
@@ -33,7 +33,6 @@
|
||||
"ajv": "^8.17.1",
|
||||
"diff": "^7.0.0",
|
||||
"dotenv": "^17.1.0",
|
||||
"gaxios": "^7.1.1",
|
||||
"glob": "^10.4.5",
|
||||
"google-auth-library": "^9.11.0",
|
||||
"html-to-text": "^9.0.5",
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { GaxiosError } from 'gaxios';
|
||||
interface GaxiosError {
|
||||
response?: {
|
||||
data?: unknown;
|
||||
};
|
||||
}
|
||||
|
||||
export function isNodeError(error: unknown): error is NodeJS.ErrnoException {
|
||||
return error instanceof Error && 'code' in error;
|
||||
@@ -33,8 +37,9 @@ interface ResponseData {
|
||||
}
|
||||
|
||||
export function toFriendlyError(error: unknown): unknown {
|
||||
if (error instanceof GaxiosError) {
|
||||
const data = parseResponseData(error);
|
||||
if (error && typeof error === 'object' && 'response' in error) {
|
||||
const gaxiosError = error as GaxiosError;
|
||||
const data = parseResponseData(gaxiosError);
|
||||
if (data.error && data.error.message && data.error.code) {
|
||||
switch (data.error.code) {
|
||||
case 400:
|
||||
@@ -58,5 +63,5 @@ function parseResponseData(error: GaxiosError): ResponseData {
|
||||
if (typeof error.response?.data === 'string') {
|
||||
return JSON.parse(error.response?.data) as ResponseData;
|
||||
}
|
||||
return typeof error.response?.data as ResponseData;
|
||||
return error.response?.data as ResponseData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user