async stack trace capturing!!!!!!!!!!!!!!!

This commit is contained in:
Skillz
2020-09-23 18:17:20 -04:00
parent 9c657e72b7
commit 5d274b90b6
2 changed files with 20 additions and 5 deletions
+19 -4
View File
@@ -197,6 +197,9 @@ async function runMethod(
},
);
const errorStack = new Error("Location In Your Files:");
Error.captureStackTrace(errorStack);
return new Promise((resolve, reject) => {
const callback = async () => {
try {
@@ -227,7 +230,7 @@ async function runMethod(
},
);
const bucketIDFromHeaders = processHeaders(url, response.headers);
handleStatusCode(response);
handleStatusCode(response, errorStack);
// Sometimes Discord returns an empty 204 response that can't be made to JSON.
if (response.status === 204) return resolve();
@@ -238,6 +241,12 @@ async function runMethod(
json.message === "You are being rate limited."
) {
if (retryCount > 10) {
eventHandlers.debug?.(
{
type: "error",
data: { method, url, body, retryCount, bucketID, errorStack },
},
);
throw new Error(Errors.RATE_LIMIT_RETRY_MAXED);
}
@@ -258,8 +267,8 @@ async function runMethod(
} catch (error) {
eventHandlers.debug?.(
{
type: "requestManagerFailed",
data: { method, url, body, retryCount, bucketID },
type: "error",
data: { method, url, body, retryCount, bucketID, errorStack },
},
);
return reject(error);
@@ -278,7 +287,7 @@ async function runMethod(
});
}
function handleStatusCode(response: Response) {
function handleStatusCode(response: Response, errorStack?: unknown) {
const status = response.status;
if (
@@ -288,6 +297,12 @@ function handleStatusCode(response: Response) {
return true;
}
eventHandlers.debug?.(
{
type: "error",
data: { errorStack },
},
);
console.error(response);
switch (status) {
+1 -1
View File
@@ -56,10 +56,10 @@ export interface DebugArg {
/** Red is for errors or urgent issues. Yellow is for warnings/alerts. Green is for actions being taken. Blue is for */
type?:
| "identifying"
| "error"
| "requestManager"
| "globallyRateLimited"
| "requestManagerSuccess"
| "requestManagerFailed"
| "requestManagerFetching"
| "requestManagerFetched"
| "requestMembersProcessing"