You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there, I started using Effect in a couple of week, and I'm curious what is the best way to use tryPromise and log the original error.
So what I do is:
Effect.gen(function*(){yield*Effect.tryPromise({try: ()=>callPromise(),catch: (error)=>newMyCustomError({message: "My custom error",cause: error})})})
And I want to log the error with Effect.logError, but cannot run effect in the catch. The best option I could find is the following, but feel like that's not the best option:
Effect.tryPromise(()=>callPromise()).pipe(Effect.tapError((error)=>Effect.logError((errorasError).message)),Effect.mapError((error)=>newMyCustomError({message: "My custom error",cause: error,})),)
Could someone provide a better option for this? Thank you 🙏
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there, I started using Effect in a couple of week, and I'm curious what is the best way to use tryPromise and log the original error.
So what I do is:
And I want to log the error with Effect.logError, but cannot run effect in the catch. The best option I could find is the following, but feel like that's not the best option:
Could someone provide a better option for this? Thank you 🙏
Beta Was this translation helpful? Give feedback.
All reactions