When an effect fails with an unexpected error Cause defines everything that may have caused the issue:
Fail<E>: when we do not recover from an expected errorDie: when an effect cannot recover or continue, hitting a dead end (for example when usingthrowor by manually callingEffect.dieorEffect.dieMessage)Interrupt: when an interrupt signal stops the execution of the effect (for example by usingEffect.interrupt)Sequential<E> | Parallel<E>: collects multiple errors in sequential or parallel effect executionsEmpty: usually seen as one of the members ofSequentialorParallelwhen one side succeeded and the other failed
export type Cause<E> = Empty | Fail<E> | Die | Interrupt | Sequential<E> | Parallel<E>There are multiple APIs in effect to cause, recover, and inspect defects. Some of the most commons are:
Effect.dieEffect.interruptLayer.orDieEffect.catchAllCauseEffect.catchAllDefectEffect.tapDefect
From a software design standpoint, defect are unrecoverable. Some examples are:
- Out of memory
- Power outage
- Stack overflow
Unlike failures, defects should never be designed as part of a normal flow, and instead you should allow the program to crash.
I encourage you to take a look at them yourself (the API reference is your best friend).
