Details
-
Bug
-
Resolution: Won't Fix
-
Major
-
None
-
Mad Hatter
Description
If a function call (such as curl) fails in JS handler, one may wish to retry the operation later. Below example illustrates it. Please include in documentation:
// Main function
|
function doSomething(params) { |
// do work using curl etc |
...
|
}
|
|
// Helper function to retry
|
function retryAfter2Hours(fn, params) { |
var retryTime = new Date(); |
retryTime.setHours(retryTime.getHours() + 2);
|
createTimer(fn, retryTime, id, params);
|
}
|
|
// Example of retrying if something goes wrong
|
var ok = doSomething(params); |
if (!ok) { |
retryAfter2Hours(doSomething, params);
|
}
|
|
// Example of retrying if exception is thrown
|
try { |
doSomething(params);
|
} catch (err) { |
retryAfter2Hours(doSomething, params);
|
}
|