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 {