Real-Serious-Games / C-Sharp-Promise

Promises library for C# for management of asynchronous operations.
MIT License
1.19k stars 149 forks source link

Add overload of Catch that returns an IPromise or IPromise<PromisedT>… #109

Open ReneB opened 4 years ago

ReneB commented 4 years ago

… 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.

ReneB commented 4 years ago

The build passes so there's that.

I've added 4 tests - 2 for the generic Promise class and 2 for the nongeneric version - which test:

1) continuation (with the value encapsulated in the promise in the generic case) when a resolved promise is passed 2) rejection when a rejected promise is passed in

In the current version, the code is backwards incompatible for the specific case of Catch blocks that throw and don't return anything, as mentioned in #77 - if you'd prefer a backwards compatible version I will rename the Catch method to something like Recover.

ReneB commented 4 years ago

@RoryDungan could you take a look at this?

joeatsalot commented 3 years ago

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.