-
Notifications
You must be signed in to change notification settings - Fork 148
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
Add overload of Catch that returns an IPromise or IPromise<PromisedT>… #109
base: master
Are you sure you want to change the base?
Add overload of Catch that returns an IPromise or IPromise<PromisedT>… #109
Conversation
… to allow asynchronous continuation These versions of Catch allow for recovery of a chain of promises by handling an error from an earlier state, then getting back into the "normal" flow of processing. Rework of PR Real-Serious-Games#77.
The build passes so there's that. I've added 4 tests - 2 for the generic
In the current version, the code is backwards incompatible for the specific case of |
@RoryDungan could you take a look at this? |
recoveryMethod(ex) | ||
.Progress(progress => resultPromise.ReportProgress(progress)) | ||
.Then(resolve => resultPromise.Resolve(resolve)) | ||
.Catch(reject => resultPromise.Reject(ex)); |
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.
resultPromise should be rejected with reject
, not ex
onRejected(ex) | ||
.Progress(progress => resultPromise.ReportProgress(progress)) | ||
.Then(() => resultPromise.Resolve()) | ||
.Catch(reject => resultPromise.Reject(ex)); |
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.
resultPromise should be rejected with reject
, not ex
promise.Reject(new Exception()); | ||
|
||
Assert.Equal(expectedValue, actualValue); | ||
} |
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.
You should add some tests to make sure the value passed into onResolved and onRejected are the same as the promise returned in the first catch.
I support adding this feature. It was one of the big omissions when I used this library. I had to add it in my own fork. |
… to allow asynchronous continuation
These versions of Catch allow for recovery of a chain of promises by
handling an error from an earlier state, then getting back into the
"normal" flow of processing.
Rework of PR #77.