From 1fa1f2b780f4d9f4729fe7258624a7a3c753c837 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Sun, 4 Jan 2026 03:33:33 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/TGHttp.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/utils/TGHttp.ts b/src/utils/TGHttp.ts index 36a674f9..df492773 100644 --- a/src/utils/TGHttp.ts +++ b/src/utils/TGHttp.ts @@ -63,17 +63,19 @@ async function TGHttp( console.debug(options); } return await fetch(url, fetchOptions) - .then((res) => { + .then(async (res) => { if (res.ok) { - const data = options.isBlob ? res.arrayBuffer() : res.json(); + const data = options.isBlob ? await res.arrayBuffer() : await res.json(); if (fullResponse) return { data, resp: res }; return data; } - throw new Error(`HTTP error! status: ${res.status}`); + await TGLogger.Error(`Fetch URL: ${url} ERROR: ${res.status} ${res.statusText}`); + throw new Error(await res.text(), { cause: `${res.status} ${res.statusText}` }); }) .catch(async (err) => { - await TGLogger.Error(`Request ${url} error`); - if (err instanceof Error || typeof err === "object") { + if (err instanceof Error) { + console.error(err.message); + } else if (typeof err === "object") { await TGLogger.Error(`Error: ${JSON.stringify(err)}`); } else { await TGLogger.Error(`Error: ${err}`);