Skip to content

Commit

Permalink
Fixed issue on nb of retries + direct link to file
Browse files Browse the repository at this point in the history
The exponential backoff was actually perform 4 times with delays of approximately 1, 2, 4 and 8s.
The last retry (after 16s) was skipped.
It also means that asking for 1 retry only with retryNumber actually meant performing 0 retry.

I also added a direct link to the right line of the right file in the Apps Script project with "directLink".
  • Loading branch information
RomainVialard authored Apr 23, 2018
1 parent 0ada882 commit 8acf26a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ErrorHandler.gs.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function expBackoff(func, options) {
var customError;

// execute func() then retry <retry> times at most if errors
for (var n = 0; n < retry; n++) {
for (var n = 0; n <= retry; n++) {
// actual exponential backoff
n && Utilities.sleep(retryDelay || (Math.pow(2, n-1) * 1000) + (Math.round(Math.random() * 1000)));

Expand Down Expand Up @@ -278,9 +278,12 @@ function logError(error, additionalParams, options) {

// Manage error Stack
if (error.lineNumber && error.fileName && error.stack) {
var directLink = "https://script.google.com/macros/d/";
directLink+= ScriptApp.getScriptId() + "/edit?f=" + error.fileName + "&s=" + error.lineNumber;
log.context.reportLocation = {
lineNumber: error.lineNumber,
filePath: error.fileName
filePath: error.fileName,
directLink: directLink
};

var addonName = additionalParams && additionalParams.addonName || undefined;
Expand Down

0 comments on commit 8acf26a

Please sign in to comment.