apperr

package
v0.0.0-...-e4d115a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 1 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeOf

func CodeOf(err error) string

CodeOf reports the error's machine-readable code, or "" when absent.

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 requires authentication (HTTP 401).
	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"
)

func KindOf

func KindOf(err error) Kind

KindOf reports the error's Kind, or "" when it carries none.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL