Add overload of Catch that returns an IPromise or IPromise<PromisedT>…#109
Add overload of Catch that returns an IPromise or IPromise<PromisedT>…#109ReneB wants to merge 1 commit intoReal-Serious-Games:masterfrom
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.
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.
resultPromise should be rejected with reject, not ex
| promise.Reject(new Exception()); | ||
|
|
||
| Assert.Equal(expectedValue, actualValue); | ||
| } |
There was a problem hiding this comment.
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.