apperror

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package apperror defines transport-independent application errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Detail

type Detail struct {
	Field string `json:"field"`
	Rule  string `json:"rule"`
}

Detail describes a public field/rule violation, never its submitted value.

type Error

type Error struct {
	// contains filtered or unexported fields
}

func New

func New(kind Kind, code int, publicMessage string) *Error

func Resolve

func Resolve(err error) *Error

Resolve prioritizes cancellation, then the first typed application error in errors.As traversal order, including Join. Unknown causes remain private.

func (*Error) Code

func (e *Error) Code() int

func (*Error) Details

func (e *Error) Details() []Detail

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Kind

func (e *Error) Kind() Kind

func (*Error) PublicMessage

func (e *Error) PublicMessage() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) WithCause

func (e *Error) WithCause(cause error) *Error

func (*Error) WithDetails

func (e *Error) WithDetails(details ...Detail) *Error

type Kind

type Kind string
const (
	InvalidArgument  Kind = "invalid_argument"
	Unauthenticated  Kind = "unauthenticated"
	Forbidden        Kind = "forbidden"
	NotFound         Kind = "not_found"
	Conflict         Kind = "conflict"
	Unavailable      Kind = "unavailable"
	Internal         Kind = "internal"
	Canceled         Kind = "canceled"
	DeadlineExceeded Kind = "deadline_exceeded"
)

Jump to

Keyboard shortcuts

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