Skip to content

Commit

Permalink
log network error info in console
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthvp committed Jan 8, 2022
1 parent f56dd01 commit 38c723d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ export class Response {
return rejectWithError(errorData);
}

/**
* This handles errors at the network level
* @param {Object} error
*/
handleRequestFailure(error: any) {
if (
!error.disableRetry &&
Expand All @@ -381,6 +385,7 @@ export class Response {
) {
// error might be transient, give it another go!
log(`[W] Encountered ${error}, retrying in ${this.bot.options.retryPause / 1000} seconds`);
console.log(error); // log the full error for upstream reporting if required
return sleep(this.bot.options.retryPause).then(() => {
return this.retry();
});
Expand Down

0 comments on commit 38c723d

Please sign in to comment.