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 13:11:02 -05:00
committed by GitHub
co-authored by meister03
parent 73452f43f5
commit cfbb1cd415
2 changed files with 9 additions and 3 deletions
+6 -1
View File
@@ -60,7 +60,12 @@ export async function runMethod<T = any>(
url: route[0] === "/" ? `${BASE_URL}/v${API_VERSION}${route}` : route, url: route[0] === "/" ? `${BASE_URL}/v${API_VERSION}${route}` : route,
method, method,
reject: (data: RestRequestRejection) => { 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); reject(restError);
}, },
respond: (data: RestRequestResponse) => respond: (data: RestRequestResponse) =>
+3 -2
View File
@@ -86,11 +86,12 @@ export async function sendRequest<T>(rest: RestManager, options: RestSendRequest
// If NOT rate limited remove from queue // If NOT rate limited remove from queue
if (response.status !== 429) { if (response.status !== 429) {
const body = response.type ? JSON.stringify(await response.json()) : undefined;
options.reject?.({ options.reject?.({
ok: false, ok: false,
status: response.status, status: response.status,
error, error,
body: response.type ? JSON.stringify(await response.json()) : undefined, body,
}); });
throw new Error( throw new Error(
@@ -98,7 +99,7 @@ export async function sendRequest<T>(rest: RestManager, options: RestSendRequest
ok: false, ok: false,
status: response.status, status: response.status,
error, error,
body: response.type ? JSON.stringify(await response.json()) : undefined, body,
}), }),
); );
} else { } else {