Fix Internal proxy Issue (#2413)

* Fix Internal proxy Issue

* deno fmt

Co-authored-by: meister03 <meisterpi@gmail.com>
This commit is contained in:
meister03
2022-09-01 20:11:02 +02:00
committed by GitHub
parent 73452f43f5
commit cfbb1cd415
2 changed files with 9 additions and 3 deletions

View File

@@ -60,7 +60,12 @@ export async function runMethod<T = any>(
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) =>

View File

@@ -86,11 +86,12 @@ export async function sendRequest<T>(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<T>(rest: RestManager, options: RestSendRequest
ok: false,
status: response.status,
error,
body: response.type ? JSON.stringify(await response.json()) : undefined,
body,
}),
);
} else {