Structured application errors
pkg/errors defines AppError, typed codes, wrapping/unwrapping, and code-to-HTTP-status mapping. Its standard codes represent not found, already exists, invalid input, unauthorized, forbidden, and internal errors.
Use New(code, message, underlying) to preserve an underlying error while returning a stable application classification. HTTPStatusCode maps unknown codes to 500. Presentation layers remain responsible for response shape and for deciding which messages are safe to expose.
Do not confuse these errors with provider-owned stable errors in service public/ packages or Huma problem responses. Cross-service consumers should rely on the owning contract's documented errors, while HTTP handlers map those errors into API responses. This shared library has no persistence, network calls, or automatic handler integration.
Code reference
See the generated errors package.