connor4312 / cockatiel

🐦 A resilience and fault-handling library. Supports Backoffs, Retries, Circuit Breakers, Timeouts, Bulkhead Isolation, and Fallbacks.
MIT License
1.59k stars 50 forks source link

Handle both error and return value of the function for retry policy #76

Closed pavansandeep2910 closed 1 year ago

pavansandeep2910 commented 1 year ago

I want to handle both errors and treat specific return values of the function as errors. it's like I want to use both handleWhen and handleWhenResult. Do you know how I can do that?

connor4312 commented 1 year ago

You make a policy like handleType(SomeError).orWhenResult(r => !r.ok)