errorsx

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPStatus

func HTTPStatus(code Code) int

HTTPStatus maps a Code to its canonical HTTP status code.

func IsCode

func IsCode(err error, code Code) bool

IsCode reports whether err carries the given Code.

func WithCode

func WithCode(err error, code Code) error

WithCode wraps err with a Code. Preserves errors.Is / errors.As chains.

Types

type Code

type Code string

Code is a machine-readable error category.

const (
	CodeInvalidArgument Code = "invalid_argument"
	CodeNotFound        Code = "not_found"
	CodeConflict        Code = "conflict"
	CodeUnauthorized    Code = "unauthorized"
	CodeForbidden       Code = "forbidden"
	CodeDeadline        Code = "deadline"
	CodeUnavailable     Code = "unavailable"
	CodeInternal        Code = "internal"
)

func CodeOf

func CodeOf(err error) Code

CodeOf returns the Code attached to err. Unknown errors return CodeInternal.

Jump to

Keyboard shortcuts

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