Versions in this module Expand all Collapse all v14 v14.0.1 Nov 13, 2026 v14.0.0 Nov 12, 2026 Changes in this version + var As = errors.As + var DefaultCORSErrorHandler context.ErrorHandler = func(ctx *context.Context, err error) + var DefaultContextErrorHandler context.ErrorHandler = func(ctx *context.Context, err error) + var DefaultPathParameterTypeErrorHandler handler.ParamErrorHandler = func(ctx *context.Context, paramIndex int, err error) + var DefaultRateLimitExceededHandler = func(ctx *context.Context) + var DefaultVersioningNotFoundHandler = func(ctx *context.Context) + var ErrRequest = fmt.Errorf("request error") + var ErrResponse = fmt.Errorf("response error") + var ErrUnexpected = Register("UNEXPECTED_ERROR", http.StatusInternalServerError) + var ErrUnexpectedErrorCode = New("unexpected error code name") + var Is = errors.Is + var Join = errors.Join + var New = errors.New + var SkipCanceled = true + var Unwrap = errors.Unwrap + func ApplyPatches() + func AsType[E error](err error) (E, bool) + func FuncHandler(fn Func) context.Handler + func FuncHandlers(funcs ...Func) context.Handlers + func FuncMiddleware(handler Func) context.Handler + func HTML(ctx *context.Context, err *Error) + func HandleAPIError(ctx *context.Context, err error) + func HandleError(ctx *context.Context, err error) bool + func HandleErrorf(ctx *context.Context, err error, format string, args ...any) bool + func HandleRequestError(ctx *context.Context, err error) bool + func HandleRequestErrorf(ctx *context.Context, err error, format string, args ...any) bool + func HandleRequestJSONError(ctx *context.Context, err error) bool + func HandleResponseJSONError(ctx *context.Context, err error) bool + func Handler(ctx *context.Context) + func NotFoundID(ctx *context.Context, resource string, id any) bool + func Private(err error) error + func Problem(ctx *context.Context, err *Error) + func RecoveryHandler(ctx *context.Context) + func RegisterErrorCode(canonicalName ErrorCodeName, httpStatusCode int) + func RegisterErrorCodeMap(errorMap map[ErrorCodeName]int) + func RegisterErrorResolver(fn ErrorResolver) + func UnwrapAll(err error) (list []error) + type ContextErrorFunc = func(ctx *context.Context, err *Error) + type Error struct + Data json.RawMessage + Detail string + ErrorCode ErrorCode + ID string + Instance string + Message string + Type string + Validation any + func Report(ctx *context.Context, err error) *Error + func (err *Error) Attrs() []slog.Attr + func (err *Error) Error() string + type ErrorCode struct + CanonicalName ErrorCodeName + Status int + func (errorCode ErrorCode) ServeFailure(ctx *context.Context, msg, detail, typeURI, instanceURI string, ...) + type ErrorCodeMap map[ErrorCodeName][]MapErrorFn + func (m ErrorCodeMap) Filter(ctx *context.Context, err error) (ErrorCodeName, error) + func (m ErrorCodeMap) MapErrorAs[E error](code ErrorCodeName, render func(E) *Error) ErrorCodeMap + func (m ErrorCodeMap) MapErrorContains(e ErrorCodeName, substr, message string) ErrorCodeMap + func (m ErrorCodeMap) MapErrorFunc(e ErrorCodeName, fn func(error) error) ErrorCodeMap + func (m ErrorCodeMap) MapErrorFuncCtx(e ErrorCodeName, fn MapErrorFn) ErrorCodeMap + func (m ErrorCodeMap) MapErrorTypes(e ErrorCodeName, targets ...any) ErrorCodeMap + func (m ErrorCodeMap) MapErrorTypesTransformed(e ErrorCodeName, targets ...any) ErrorCodeMap + func (m ErrorCodeMap) MapErrors(e ErrorCodeName, targets ...error) ErrorCodeMap + type ErrorCodeName string + var Aborted ErrorCodeName = Register("ABORTED", http.StatusConflict) + var AlreadyExists ErrorCodeName = Register("ALREADY_EXISTS", http.StatusConflict) + var BadGateway ErrorCodeName = Register("BAD_GATEWAY", http.StatusBadGateway) + var BandwidthLimitExceeded ErrorCodeName = Register("BANDWIDTH_LIMIT_EXCEEDED", context.StatusBandwidthLimitExceeded) + var BlockedByWindowsParentalControls ErrorCodeName = Register("BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS", ...) + var Cancelled ErrorCodeName = Register("CANCELLED", http.StatusRequestTimeout) + var DataLoss ErrorCodeName = Register("DATA_LOSS", http.StatusInternalServerError) + var DeadlineExceeded ErrorCodeName = Register("DEADLINE_EXCEEDED", http.StatusGatewayTimeout) + var ExpectationFailed ErrorCodeName = Register("EXPECTATION_FAILED", http.StatusExpectationFailed) + var FailedDependency ErrorCodeName = Register("FAILED_DEPENDENCY", http.StatusFailedDependency) + var FailedPrecondition ErrorCodeName = Register("FAILED_PRECONDITION", http.StatusBadRequest) + var Gone ErrorCodeName = Register("GONE", http.StatusGone) + var HTTPVersionNotSupported ErrorCodeName = Register("HTTP_VERSION_NOT_SUPPORTED", http.StatusHTTPVersionNotSupported) + var ImATeapot ErrorCodeName = Register("IM_A_TEAPOT", http.StatusTeapot) + var InsufficientStorage ErrorCodeName = Register("INSUFFICIENT_STORAGE", http.StatusInsufficientStorage) + var Internal ErrorCodeName = Register("INTERNAL", http.StatusInternalServerError) + var InvalidArgument ErrorCodeName = Register("INVALID_ARGUMENT", http.StatusBadRequest) + var InvalidSSLCertificate ErrorCodeName = Register("INVALID_SSL_CERTIFICATE", context.StatusInvalidSSLCertificate) + var InvalidToken ErrorCodeName = Register("INVALID_TOKEN", context.StatusInvalidToken) + var LengthRequired ErrorCodeName = Register("LENGTH_REQUIRED", http.StatusLengthRequired) + var Locked ErrorCodeName = Register("LOCKED", http.StatusLocked) + var LoopDetected ErrorCodeName = Register("LOOP_DETECTED", http.StatusLoopDetected) + var MethodNotAllowed ErrorCodeName = Register("METHOD_NOT_ALLOWED", http.StatusMethodNotAllowed) + var MisdirectedRequest ErrorCodeName = Register("MISDIRECTED_REQUEST", http.StatusMisdirectedRequest) + var NetworkAuthenticationRequired ErrorCodeName = Register("NETWORK_AUTHENTICATION_REQUIRED", http.StatusNetworkAuthenticationRequired) + var NetworkReadTimeout ErrorCodeName = Register("NETWORK_READ_TIMEOUT", context.StatusNetworkReadTimeout) + var NotAcceptable ErrorCodeName = Register("NOT_ACCEPTABLE", http.StatusNotAcceptable) + var NotExtended ErrorCodeName = Register("NOT_EXTENDED", http.StatusNotExtended) + var NotFound ErrorCodeName = Register("NOT_FOUND", http.StatusNotFound) + var OutOfRange ErrorCodeName = Register("OUT_OF_RANGE", http.StatusBadRequest) + var PageExpired ErrorCodeName = Register("PAGE_EXPIRED", context.StatusPageExpired) + var PaymentRequired ErrorCodeName = Register("PAYMENT_REQUIRED", http.StatusPaymentRequired) + var PermissionDenied ErrorCodeName = Register("PERMISSION_DENIED", http.StatusForbidden) + var PreconditionFailed ErrorCodeName = Register("PRECONDITION_FAILED", http.StatusPreconditionFailed) + var PreconditionRequired ErrorCodeName = Register("PRECONDITION_REQUIRED", http.StatusPreconditionRequired) + var ProxyAuthRequired ErrorCodeName = Register("PROXY_AUTH_REQUIRED", http.StatusProxyAuthRequired) + var RequestHeaderFieldsTooLarge ErrorCodeName = Register("REQUEST_HEADER_FIELDS_TOO_LARGE", http.StatusRequestHeaderFieldsTooLarge) + var RequestTimeout ErrorCodeName = Register("REQUEST_TIMEOUT", http.StatusRequestTimeout) + var RequestURITooLong ErrorCodeName = Register("REQUEST_URI_TOO_LONG", http.StatusRequestURITooLong) + var RequestedRangeNotSatisfiable ErrorCodeName = Register("REQUESTED_RANGE_NOT_SATISFIABLE", http.StatusRequestedRangeNotSatisfiable) + var ResourceExhausted ErrorCodeName = Register("RESOURCE_EXHAUSTED", http.StatusTooManyRequests) + var SiteFrozen ErrorCodeName = Register("SITE_FROZEN", context.StatusSiteFrozen) + var SiteOverloaded ErrorCodeName = Register("SITE_OVERLOADED", context.StatusSiteOverloaded) + var TokenRequired ErrorCodeName = Register("TOKEN_REQUIRED", context.StatusTokenRequired) + var TooEarly ErrorCodeName = Register("TOO_EARLY", http.StatusTooEarly) + var TooLarge ErrorCodeName = Register("TOO_LARGE", http.StatusRequestEntityTooLarge) + var Unauthenticated ErrorCodeName = Register("UNAUTHENTICATED", http.StatusUnauthorized) + var Unavailable ErrorCodeName = Register("UNAVAILABLE", http.StatusServiceUnavailable) + var UnavailableForLegalReasons ErrorCodeName = Register("UNAVAILABLE_FOR_LEGAL_REASONS", http.StatusUnavailableForLegalReasons) + var Unimplemented ErrorCodeName = Register("UNIMPLEMENTED", http.StatusNotImplemented) + var Unknown ErrorCodeName = Register("UNKNOWN", http.StatusInternalServerError) + var UnprocessableEntity ErrorCodeName = Register("UNPROCESSABLE_ENTITY", http.StatusUnprocessableEntity) + var UnsupportedMediaType ErrorCodeName = Register("UNSUPPORTED_MEDIA_TYPE", http.StatusUnsupportedMediaType) + var UpgradeRequired ErrorCodeName = Register("UPGRADE_REQUIRED", http.StatusUpgradeRequired) + var VariantAlsoNegotiates ErrorCodeName = Register("VARIANT_ALSO_NEGOTIATES", http.StatusVariantAlsoNegotiates) + func Register(httpErrorCanonicalName string, httpStatusCode int) ErrorCodeName + func (e ErrorCodeName) Data(ctx *context.Context, msg string, data any) + func (e ErrorCodeName) DataWithDetail(ctx *context.Context, msg, detail string, data any) + func (e ErrorCodeName) DenySort(message string) context.PaginationOption + func (e ErrorCodeName) Detail(ctx *context.Context, msg, detail string) + func (e ErrorCodeName) Detailf(ctx *context.Context, msg, detail string, detailArgs ...any) + func (e ErrorCodeName) Err(ctx *context.Context, err error) + func (e ErrorCodeName) ErrPrivate(ctx *context.Context, err error) + func (e ErrorCodeName) Error() string + func (e ErrorCodeName) Handle(ctx *context.Context, err error) bool + func (e ErrorCodeName) Log(ctx *context.Context, format string, args ...any) + func (e ErrorCodeName) LogErr(ctx *context.Context, err error) + func (e ErrorCodeName) Message(ctx *context.Context, message string) + func (e ErrorCodeName) Messagef(ctx *context.Context, format string, args ...any) + func (e ErrorCodeName) Problem(ctx *context.Context, title, detail, typeURI, instanceURI string, extra ...any) + func (e ErrorCodeName) Report(ctx *context.Context, err error) *Error + func (e ErrorCodeName) String() string + func (e ErrorCodeName) Validation(ctx *context.Context, validationErrors ...ValidationError) + func (e ErrorCodeName) Wrap(err error) error + type ErrorResolver func(ctx *context.Context, err error) bool + type Func = func(*context.Context) error + type IDGeneratorFunc = func(ctx *context.Context) string + type LogErrorFunc = func(ctx *context.Context, err error) + var LogError LogErrorFunc = func(ctx *context.Context, err error) { ... } + type MapErrorFn func(ctx *context.Context, err error) error + type Options struct + func NewOptions() *Options + func (opts *Options) ErrorCodeMap() ErrorCodeMap + func (opts *Options) Handler() context.Handler + func (opts *Options) HandlerWithError() Func + func (opts *Options) HasRenderer() bool + func (opts *Options) MapErrorAs[E error](code ErrorCodeName, render func(E) *Error) *Options + func (opts *Options) MapErrorContains(e ErrorCodeName, substr, message string) *Options + func (opts *Options) MapErrorFunc(e ErrorCodeName, fn func(error) error) *Options + func (opts *Options) MapErrorFuncCtx(e ErrorCodeName, fn MapErrorFn) *Options + func (opts *Options) MapErrorTypes(e ErrorCodeName, targets ...any) *Options + func (opts *Options) MapErrors(e ErrorCodeName, targets ...error) *Options + func (opts *Options) SetCollector(fn ContextErrorFunc) *Options + func (opts *Options) SetID(id string) *Options + func (opts *Options) SetIDGenerator(fn IDGeneratorFunc) *Options + func (opts *Options) SetLogger(fn LogErrorFunc) *Options + func (opts *Options) SetRenderer(fn ContextErrorFunc) *Options + type Router struct + func NewRouter(r router.Router) *Router + func (r *Router) Any(path string, funcs ...Func) *router.RouteRegistry + func (r *Router) Connect(path string, funcs ...Func) *router.Route + func (r *Router) Delete(path string, funcs ...Func) *router.Route + func (r *Router) Get(path string, funcs ...Func) *router.Route + func (r *Router) Handle(method, path string, funcs ...Func) *router.RouteRegistry + func (r *Router) HandleServer(path string, server ServerHandler) + func (r *Router) Head(path string, funcs ...Func) *router.Route + func (r *Router) Options(path string, funcs ...Func) *router.Route + func (r *Router) Patch(path string, funcs ...Func) *router.Route + func (r *Router) Post(path string, funcs ...Func) *router.Route + func (r *Router) Put(path string, funcs ...Func) *router.Route + func (r *Router) Query(path string, funcs ...Func) *router.Route + func (r *Router) Subdomain(subdomain string, middlewareFuncs ...Func) *Router + func (r *Router) Trace(path string, funcs ...Func) *router.Route + func (r *Router) Use(funcs ...Func) + func (r *Router) UseOnce(funcs ...Func) + func (r *Router) UseRouter(funcs ...Func) + type Routing func(*Router) + func (c Routing) Routing(r router.Router) + type ServerHandler interface + HandleRequest func(*context.Context) error + type ValidationError interface + GetReason func() string + type ValidationErrors []ValidationError + func (errs ValidationErrors) Error() string