What's the best way to deal with an async API where I want to catch some errors and ignore others (i.e. let the program die)?
So far I've been using the pattern below, however 1) it feels a bit verbose and unnecessary to create wrappers for the "irrelevant" errors, and 2) it doesn't cause the program to just die when an IrrelevantError occurs.
Effect.tryPromise({ try: () => someThirdPartyFn(), catch: (e) => { if (weCareAbout(e)) { return new RelevantError(e) } else { return new IrrelevantError(e) } }})
Effect.tryPromise({ try: () => someThirdPartyFn(), catch: (e) => { if (weCareAbout(e)) { return new RelevantError(e) } else { return new IrrelevantError(e) } }})
I considered just using
Effect.promise
Effect.promise
to run the promise, then
Effect.catchSomeDefect
Effect.catchSomeDefect
to recover from the errors I care about, however that seems like an anti-pattern (and