Documentation
¶
Overview ¶
Package errorstest provides test assertions on the error code a pkg/errors chain reports.
Consumers such as errors.ExitCodeFromError read the code of the outermost *errors.StructuredError. errors.Is matches a code anywhere in the chain, so an assertion built on it still passes when the expected code is buried under a wrap that reports a different one. Use these helpers to assert what a consumer reads. Keep errors.Is for asserting that a code is absent, where matching anywhere in the chain is the stricter check.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReportedCode ¶
ReportedCode returns the Code of the outermost *errors.StructuredError in err's Unwrap chain, or the empty code when the chain has none. It sees through non-structured wraps such as fmt.Errorf("%w", ...).
Types ¶
This section is empty.