-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement throw error with original error and reraise error #19
Conversation
indahreforsiana
commented
Aug 25, 2022
- implement throw error with the original error
- add the option reraise error to rethrow the original error when it's reached max attempts
@vcfvct any comment, about this pull request? |
@ibrohimislam this PR has conflict from the beginning ~ |
yes, the conflict is because #18. and it's about the same issue. |
what do you think about the implementation? the conflict is easy to resolve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great overall. Thanks for the contribution.
I left some minor comments, and please fix the conflict. @indahreforsiana
@@ -11,6 +11,7 @@ | |||
"declarationMap": true, | |||
"skipLibCheck": true, | |||
"lib": [ | |||
"dom", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason we need dom
here?
return await fn.apply(this, args); | ||
} catch (e) { | ||
if (i == maxAttempts) { | ||
if (options.reraise) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we rename this option as something like useOriginalError
to reduce confusion?
throw e; | ||
} | ||
backOff && (await sleep(backOff)); | ||
if (options.backOffPolicy === BackOffPolicy.ExponentialBackOffPolicy) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great simplification. 👍
} */ | ||
public retryCount: number; | ||
public originalError: Error; | ||
constructor(originalError: Error, retryCount: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is a public/exported
class, I guess it would be better to make them optional to keep backward comparability. What do you think?
oh, i was not looking much detail as there's conflict. Just took a look and left some comments. |
@indahreforsiana @ibrohimislam Since this has been pending here for month and the comments are not addressed. I have to implement that myself at #23 . Thanks for your contribution. |