apperr

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code string

Code represents a stable, machine-readable error category.

const (
	InvalidInput Code = "INVALID_INPUT"
	NotFound     Code = "NOT_FOUND"
	Conflict     Code = "CONFLICT"
	Unauthorized Code = "UNAUTHORIZED"
	Forbidden    Code = "FORBIDDEN"
	Internal     Code = "INTERNAL"
	Unavailable  Code = "UNAVAILABLE"
)

func CodeOf

func CodeOf(err error) Code

CodeOf returns the first Code found in the error chain, or Internal if none.

type Error

type Error struct {
	Op      string      // operation name (optional)
	Code    Code        // error code
	Message string      // human-friendly message
	Err     error       // wrapped error (optional)
	Meta    interface{} // additional metadata (optional)
}

Error is the application's rich error type.

func E

func E(op string, code Code, err error, message string, meta ...interface{}) *Error

E constructs an *Error. op, code and message are recommended; err and meta are optional.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Jump to

Keyboard shortcuts

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