Effect CommunityEC
Effect Community3y ago
3 replies
bigpopakap

Recovering from errors in generator syntax

Just making sure I understand this properly: in generator syntax, the only way to recover from an error is from within the $() (or _()), right?

For example:
Effect.gen(function*($) {
   const a = yield* $(
       someEffectThatMightFail(),
       Effect.orElse(() =>
           // do some Effect to recover
       )
   ),
});

That's the only place you can deal with errors within a generator. Is that right? Or is there some other strategy I'm overlooking?
Was this page helpful?