I am implementing a retry mechanism in a node.js application as follows:
async addComments(id: string, comments: string[]): Promise<any> {
for (let retry = 1; retry <= 3; retry++) {
try {
// logic goes here...
return result;
} catch (err) {
// Exception log here
this.loggerService.logException(err.message, err.stack);
}
}
}
Am I doing it right?