EffectTalk

Effect.tryPromise for async operations

Wrap Promise-returning code with `Effect.tryPromise` to convert rejections into the error channel. This keeps your errors typed and composable.

In the anti-pattern, we use raw Promises and lose type safety. In the Effect way, we wrap async operations for consistency.

  • Use `Effect.tryPromise({ try, catch })` to wrap Promise-returning code
  • The `catch` handler converts rejections to typed errors
  • The result is an Effect - compose it with pipe, map, etc.
Loading code editor...