From cfbb1cd4154a5c0165aa95758b9ef43c4fda6919 Mon Sep 17 00:00:00 2001 From: meister03 <69507874+meister03@users.noreply.github.com> Date: Thu, 1 Sep 2022 20:11:02 +0200 Subject: [PATCH] Fix Internal proxy Issue (#2413) * Fix Internal proxy Issue * deno fmt Co-authored-by: meister03 --- rest/runMethod.ts | 7 ++++++- rest/sendRequest.ts | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/rest/runMethod.ts b/rest/runMethod.ts index ccae54913..8be85dcf8 100644 --- a/rest/runMethod.ts +++ b/rest/runMethod.ts @@ -60,7 +60,12 @@ export async function runMethod( url: route[0] === "/" ? `${BASE_URL}/v${API_VERSION}${route}` : route, method, reject: (data: RestRequestRejection) => { - const restError = rest.convertRestError(errorStack, data); + const newError = new Error("Location:"); + newError.stack = errorStack.stack as Error["stack"]; + const restError = rest.convertRestError( + newError, + data, + ); reject(restError); }, respond: (data: RestRequestResponse) => diff --git a/rest/sendRequest.ts b/rest/sendRequest.ts index b8b248e60..be1a9f359 100644 --- a/rest/sendRequest.ts +++ b/rest/sendRequest.ts @@ -86,11 +86,12 @@ export async function sendRequest(rest: RestManager, options: RestSendRequest // If NOT rate limited remove from queue if (response.status !== 429) { + const body = response.type ? JSON.stringify(await response.json()) : undefined; options.reject?.({ ok: false, status: response.status, error, - body: response.type ? JSON.stringify(await response.json()) : undefined, + body, }); throw new Error( @@ -98,7 +99,7 @@ export async function sendRequest(rest: RestManager, options: RestSendRequest ok: false, status: response.status, error, - body: response.type ? JSON.stringify(await response.json()) : undefined, + body, }), ); } else {