From 7b95663a9ef31036367c066ccbf0021423278f40 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Thu, 19 Aug 2021 07:04:07 +0900 Subject: [PATCH] Fix #1214 by adding more info in the ratelimited error exception message (#1312) * Fix #1214 by adding more info in the ratelimited error exception message * Add url to the invalid retry-after data pattern as well --- packages/web-api/src/WebClient.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/web-api/src/WebClient.ts b/packages/web-api/src/WebClient.ts index 6d4bc4153..d63e09c96 100644 --- a/packages/web-api/src/WebClient.ts +++ b/packages/web-api/src/WebClient.ts @@ -344,10 +344,11 @@ export class WebClient extends Methods { await delay(retrySec * 1000); // resume the request queue and throw a non-abort error to signal a retry this.requestQueue.start(); - throw Error('A rate limit was exceeded.'); + // TODO: We may want to have more detailed info such as team_id, params except tokens, and so on. + throw Error(`A rate limit was exceeded (url: ${url}, retry-after: ${retrySec})`); } else { // TODO: turn this into some CodedError - throw new AbortError(new Error('Retry header did not contain a valid timeout.')); + throw new AbortError(new Error(`Retry header did not contain a valid timeout (url: ${url})`)); } }