Documentation
¶
Overview ¶
Package catch implements the catch-by-type combinators (CatchAs, CatchIs, MapErrorAs and TapErrorAs) once for all monads whose error channel is error. Each monad passes in its own ChainLeft, TapLeft, MapLeft and Left.
Index ¶
- func CatchAs[E error, HKTB, OP any](chainLeft func(func(error) HKTB) OP, fromLeft func(error) HKTB, f func(E) HKTB) OP
- func CatchIs[HKTB, OP any](chainLeft func(func(error) HKTB) OP, fromLeft func(error) HKTB, target error, ...) OP
- func ErrorAs[E error](err error) ET.Either[error, E]
- func ErrorIs(target error) func(error) ET.Either[error, error]
- func MapAs[E error](f func(E) error) func(error) error
- func MapErrorAs[E error, OP any](mapLeft func(func(error) error) OP, f func(E) error) OP
- func OnMatch[E, HKTB any](fromLeft func(error) HKTB, match func(error) ET.Either[error, E], ...) func(error) HKTB
- func OnMatchI[E, B any](match func(error) ET.Either[error, E], f func(E) (B, error)) func(error) (B, error)
- func TapErrorAs[E error, HKTB, OP any](tapLeft func(func(error) HKTB) OP, fromLeft func(error) HKTB, f func(E) HKTB) OP
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CatchAs ¶
func CatchAs[E error, HKTB, OP any]( chainLeft func(func(error) HKTB) OP, fromLeft func(error) HKTB, f func(E) HKTB, ) OP
CatchAs recovers from errors of type E with f.
func CatchIs ¶
func CatchIs[HKTB, OP any]( chainLeft func(func(error) HKTB) OP, fromLeft func(error) HKTB, target error, f func(error) HKTB, ) OP
CatchIs recovers from errors that match target with f.
func ErrorAs ¶
ErrorAs returns the E found in the chain of err as the Right value, or err itself as the Left value.
func ErrorIs ¶
ErrorIs returns a function that returns err as the Right value if errors.Is(err, target) holds, and as the Left value otherwise.
func MapAs ¶
MapAs returns an error mapping that replaces errors of type E by f applied to them and keeps all other errors.
func MapErrorAs ¶
MapErrorAs replaces errors of type E by f applied to them.
func OnMatch ¶
func OnMatch[E, HKTB any]( fromLeft func(error) HKTB, match func(error) ET.Either[error, E], f func(E) HKTB, ) func(error) HKTB
OnMatch returns an error handler that applies f to the errors selected by match and fails with the original error otherwise.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package catchtest is a shared test suite for the error channel of the monads whose error type is error: the catch-by-type combinators (CatchAs, CatchIs, MapErrorAs, TapErrorAs) and the primitives they build on (ChainLeft, OrElse, MapLeft, ChainFirstLeft, TapLeft).
|
Package catchtest is a shared test suite for the error channel of the monads whose error type is error: the catch-by-type combinators (CatchAs, CatchIs, MapErrorAs, TapErrorAs) and the primitives they build on (ChainLeft, OrElse, MapLeft, ChainFirstLeft, TapLeft). |