Effect CommunityEC
Effect Community3y ago
1946 replies
Stephen Bluck

Using Cause to Handle Errors in TypeScript

Is something like this possible?
class HttpError extends Data.TaggedClass('HttpError')<{}> {}

declare function fetch<A>(): Effect.Effect<never, HttpError, A>;

const getUser = pipe(fetch<string>(), Effect.orDie);

const program = pipe(
  getUser,
  Effect.catchAllCause((e) => {
    // do something with HttpError
  })
);


I want to deal with an error but not have the error as part of my E. I think this is what Cause is for right?
Was this page helpful?