Documentation
¶
Overview ¶
Package errors is the project error taxonomy. It maps the DB layer's namespaced result codes (`err:domain:reason`, e.g. from result_error('err:document:notFound', …)) to Azugo HTTP error types and to safe client messages, so every service returns consistent HTTP status codes and never leaks internals.
Auth-specific mappings stay in go-authbyte; this package covers the general domain/data errors. Where Azugo lacks a matching error type (e.g. 409 Conflict), this package supplies one that implements Azugo's ResponseStatusCode and SafeError interfaces so ctx.Error(err) maps it automatically.
Index ¶
Constants ¶
const Prefix = "err"
Prefix is the namespace every DB result code carries.
Variables ¶
This section is empty.
Functions ¶
func FromResultCode ¶
FromResultCode maps a DB namespaced result code to the Azugo HTTP error type the service should return. The optional safeMsg overrides the default client-safe message for the mapped error where the type carries one.
Unrecognized codes map to InternalError (HTTP 500) with a fixed safe message, so an unmapped DB error can never leak its internals to the client.
Types ¶
type Code ¶
type Code struct {
// Domain is the resource/area, e.g. "document", "envelope", "identity".
Domain string
// Reason is the specific failure, e.g. "notFound", "forbidden", "conflict".
Reason string
}
Code is a parsed DB result code of the form `err:domain:reason`.
func ParseCode ¶
ParseCode splits a namespaced result code (`err:domain:reason`) into its parts. ok is false if the value is not a recognized result code (missing the `err:` prefix). Extra colon-separated segments beyond domain are folded into the domain so codes like `err:document:slot:notFound` still resolve a reason.
type ConflictError ¶
type ConflictError struct {
// Resource is the conflicting resource (used in the safe message).
Resource string
}
ConflictError reports a state conflict (HTTP 409). Azugo/core has no conflict type, so the taxonomy defines one here.
func (ConflictError) Error ¶
func (e ConflictError) Error() string
func (ConflictError) SafeError ¶
func (e ConflictError) SafeError() string
SafeError returns a client-safe message.
func (ConflictError) StatusCode ¶
func (ConflictError) StatusCode() int
StatusCode returns HTTP 409 Conflict.
type GoneError ¶
type GoneError struct {
Resource string
}
GoneError reports a resource that existed but is no longer available (HTTP 410), e.g. an expired signing envelope.
type InternalError ¶
type InternalError struct {
Err error
}
InternalError is the safe fallback for an unmapped or genuinely internal failure: it returns HTTP 500 with a fixed, non-leaking message while keeping the underlying error for server-side logging.
func (InternalError) Error ¶
func (e InternalError) Error() string
func (InternalError) SafeError ¶
func (InternalError) SafeError() string
SafeError returns a fixed message that never exposes internals.
func (InternalError) StatusCode ¶
func (InternalError) StatusCode() int
StatusCode returns HTTP 500 Internal Server Error.
func (InternalError) Unwrap ¶
func (e InternalError) Unwrap() error
Unwrap exposes the wrapped error for errors.Is/As and logging.