promise-retry: only print stack on last attempt
This commit is contained in:
@@ -16,9 +16,9 @@ async function promiseRetry(options, asyncFunction) {
|
||||
try {
|
||||
return await asyncFunction(i+1 /* attempt */);
|
||||
} catch (error) {
|
||||
if (options.debug) options.debug(`Attempt ${i+1} failed. Will retry: ${error.message} ${i === times-1 ? error.stack : ''}`); // only print stack on last error
|
||||
if (i === times - 1) throw error;
|
||||
if (options.retry && !options.retry(error)) throw error; // no more retry
|
||||
if (options.debug) options.debug(`Attempt ${i+1} failed. Will retry: ${error.message} ${error.stack}`);
|
||||
await timers.setTimeout(interval);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user