Documentation
¶
Overview ¶
Package apperr standardizes client-facing errors: transports map the closed set of kinds — never individual codes — to a status, so modules add codes without touching shared files.
Index ¶
- func CodeOf(err error) string
- func Conflict(code, public string) oops.OopsErrorBuilder
- func Forbidden(code, public string) oops.OopsErrorBuilder
- func Invalid(code, public string) oops.OopsErrorBuilder
- func New(kind Kind, code, public string) oops.OopsErrorBuilder
- func NotFound(code, public string) oops.OopsErrorBuilder
- func Unauthorized(code, public string) oops.OopsErrorBuilder
- func Unprocessable(code, public string) oops.OopsErrorBuilder
- type Kind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Conflict ¶
func Conflict(code, public string) oops.OopsErrorBuilder
func Forbidden ¶
func Forbidden(code, public string) oops.OopsErrorBuilder
func Invalid ¶
func Invalid(code, public string) oops.OopsErrorBuilder
func New ¶
func New(kind Kind, code, public string) oops.OopsErrorBuilder
New starts an error of the given kind: code is the stable identifier sent to clients, public the message safe to expose. Finish with .Wrap/.Errorf.
func NotFound ¶
func NotFound(code, public string) oops.OopsErrorBuilder
func Unauthorized ¶
func Unauthorized(code, public string) oops.OopsErrorBuilder
func Unprocessable ¶
func Unprocessable(code, public string) oops.OopsErrorBuilder
Types ¶
type Kind ¶
type Kind string
Kind classifies an application error for transport mapping.
const ( // KindInvalid rejects malformed input (HTTP 400). KindInvalid Kind = "invalid" KindUnauthorized Kind = "unauthorized" // KindForbidden denies access (HTTP 403). KindForbidden Kind = "forbidden" // KindNotFound reports a missing resource (HTTP 404). KindNotFound Kind = "not_found" // KindConflict reports a state conflict, e.g. a taken name (HTTP 409). KindConflict Kind = "conflict" // KindUnprocessable rejects a semantically impossible request, e.g. a // reference to a missing row (HTTP 422). KindUnprocessable Kind = "unprocessable" )
Click to show internal directories.
Click to hide internal directories.