Handling Errors with catchTag
When an Effect can fail, you need to handle the error. Use Effect.catchTag to handle specific error types.
In the anti-pattern, we ignore the error type and just run the Effect. In the Effect way, we explicitly handle the error.
- Use
Effect.catchTag(tag, handler)to handle specific error types - The handler receives the error and returns a new Effect
- After catching, the error type is removed from the Effect signature
Loading code editor...