Documentation
¶
Overview ¶
Package errs defines the project's typed error envelope.
Every service handler returning an error eventually maps it onto an HTTP status, a gRPC code, or a CLI exit. Doing that mapping once, here, keeps boundary translation consistent and prevents every service from inventing its own private "ErrNotFound" type.
Usage:
if user == nil {
return errs.New(errs.CodeNotFound, "user not found")
}
At the HTTP boundary:
switch errs.CodeOf(err) {
case errs.CodeNotFound: c.Status(http.StatusNotFound)
case errs.CodeInvalidInput: c.Status(http.StatusBadRequest)
...
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Code ¶
type Code string
Code is a stable identifier for a class of failures. Choose codes that describe the kind of error ("not_found"), not the specific cause — the message field carries the cause-specific detail.
type Error ¶
Error is the project's canonical typed error. It implements the standard error interface and wraps an underlying cause so errors.Is and errors.As still work end-to-end.