25 lines
819 B
Go
25 lines
819 B
Go
|
|
package xerrors_test
|
||
|
|
|
||
|
|
import "code.nochebuena.dev/go/xerrors"
|
||
|
|
|
||
|
|
// Compile-time contract verification.
|
||
|
|
//
|
||
|
|
// These assertions are zero-cost at runtime — the nil pointers are never
|
||
|
|
// dereferenced. If any method is removed or its signature changes, the build
|
||
|
|
// fails immediately here rather than at a distant call site in another module.
|
||
|
|
|
||
|
|
// richError is the shape that logz and other consumers expect from any structured
|
||
|
|
// error produced by this package. Adding methods to Err is non-breaking. Removing
|
||
|
|
// any of these or changing their signature is a breaking change.
|
||
|
|
var _ interface {
|
||
|
|
error
|
||
|
|
Unwrap() error
|
||
|
|
ErrorCode() string
|
||
|
|
ErrorContext() map[string]any
|
||
|
|
} = (*xerrors.Err)(nil)
|
||
|
|
|
||
|
|
// jsonMarshaler verifies Err implements json.Marshaler.
|
||
|
|
var _ interface {
|
||
|
|
MarshalJSON() ([]byte, error)
|
||
|
|
} = (*xerrors.Err)(nil)
|