Files
xerrors/compliance_test.go
Rene Nochebuena 3cc36801a1 feat(xerrors): initial stable release v0.9.0
Structured application errors with typed codes, cause chaining, key-value context fields, and zero-import logz enrichment bridge.

What's included:
- `*Err` type implementing error, errors.Unwrap, json.Marshaler, ErrorCode(), and ErrorContext()
- Twelve typed Code constants aligned with gRPC canonical status names
- New / Wrap factory constructors plus InvalidInput / NotFound / Internal convenience constructors
- Builder methods WithContext and WithError for attaching structured fields and causes
- Duck-typed ErrorCode() / ErrorContext() bridge so logz auto-enriches log records without an import

Tested-via: todo-api POC integration
Reviewed-against: docs/adr/
2026-03-18 13:09:31 -06:00

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)