From 5aa8788f782509c96b4eda8405b3abc47c10f57e Mon Sep 17 00:00:00 2001 From: shrayus-masanam <45981228+shrayus-masanam@users.noreply.github.com> Date: Wed, 17 May 2023 18:58:45 -0400 Subject: [PATCH] 502 error handling --- src/disbox-file-manager.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/disbox-file-manager.js b/src/disbox-file-manager.js index fd5268a..96d17ba 100644 --- a/src/disbox-file-manager.js +++ b/src/disbox-file-manager.js @@ -97,8 +97,11 @@ class DiscordWebhookClient { this.rateLimitWaits[type] = (retryAfter) * 1000; console.log("Rate limit exceeded, retrying"); return await this.fetchFromApi(path, {method, body, type}); - } - if (status >= 400) { + } else if (status === 502) { + this.rateLimitWaits[type] = 10 * 1000; + console.log("Gateway unavailable, retrying"); + return await this.fetchFromApi(path, {method, body, type}); + } else if (status >= 400) { throw new Error(`Failed to ${type} with status ${status}: ${await response.text()}`); } return response;