Documentation ¶
Index ¶
- func HasInterface(err error, referenceInterface interface{}) bool
- func HasType(err error, referenceType error) bool
- func If(err error, pred func(err error) (interface{}, bool)) (interface{}, bool)
- func Is(err, reference error) bool
- func IsAny(err error, references ...error) bool
- func Mark(err error, reference error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasInterface ¶ added in v1.5.0
HasInterface returns true if err contains an error which implements the interface pointed to by referenceInterface. The type of referenceInterface must be a pointer to an interface type. If referenceInterface is not a pointer to an interface, this function will panic.
func HasType ¶ added in v1.4.0
HasType returns true iff err contains an error whose concrete type matches that of referenceType.
func If ¶
If iterates on the error's causal chain and returns a predicate's return value the first time the predicate returns true.
Note: if any of the error types has been migrated from a previous package location or a different type, ensure that RegisterTypeMigration() was called prior to If().
func Is ¶
Is determines whether one of the causes of the given error or any of its causes is equivalent to some reference error.
As in the Go standard library, an error is considered to match a reference error if it is equal to that target or if it implements a method Is(error) bool such that Is(reference) returns true.
Note: the inverse is not true - making an Is(reference) method return false does not imply that errors.Is() also returns false. Errors can be equal because their network equality marker is the same. To force errors to appear different to Is(), use errors.Mark().
Note: if any of the error types has been migrated from a previous package location or a different type, ensure that RegisterTypeMigration() was called prior to Is().
func IsAny ¶
IsAny is like Is except that multiple references are compared.
Note: if any of the error types has been migrated from a previous package location or a different type, ensure that RegisterTypeMigration() was called prior to IsAny().
Types ¶
This section is empty.