Clarification on Effect Failure Mechanisms in Effect-Typed Programs
are the following notes correct:
There are only three ways of an effect-typed program failing with its expected error type
1. Returning
2. Returning
The nested call
3. Returning
The nested call
Note that:
- Using
- Using
depending on whether the effect constructor used is designed to anticipate an error.
There are only three ways of an effect-typed program failing with its expected error type
E in Effect<A, E, R>1. Returning
Effect.fail(e) directly, resulting in Effect<unknown, E>.2. Returning
Effect.try(..) whose program calls throw(e), resulting in Effect<unknown, UnknownException>.The nested call
throw(e) is effectively converted to return Effect.fail(e)3. Returning
Effect.tryPromise(..) whose program returns Promise.reject(e), resulting in Effect<unknown, UnknownException>The nested call
Promise.reject(e) is effectively converted to return Effect.fail(e).Note that:
- Using
throw in a Promise results in a returning a rejected promise.- Using
throw in an Effect results in returning either an expected error or a defect,depending on whether the effect constructor used is designed to anticipate an error.
