errorcategory

package
v1.50.4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errorcategory attaches stable categories to errors without changing their messages or unwrapping behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf added in v1.50.1

func Errorf(category Category, format string, args ...any) error

Errorf formats an error with an explicit category.

func New added in v1.50.1

func New(category Category, message string) error

New creates an error with an explicit category.

func UserInputErrorf

func UserInputErrorf(format string, args ...any) error

UserInputErrorf formats an error categorized as UserInput.

func With

func With(err error, category Category) error

With returns an error with an explicit category. A nil error remains nil.

Types

type Categorized

type Categorized interface {
	error
	ErrorCategory() Category
}

Categorized is implemented by errors with an explicit category.

type Category

type Category string

Category identifies the source of an error.

const (
	UserInput  Category = "user_input"
	Auth       Category = "auth"
	Network    Category = "network"
	API        Category = "api"
	Filesystem Category = "filesystem"
	Internal   Category = "internal"
	Panic      Category = "panic"
)

func Get

func Get(err error) (Category, bool)

Get returns the first explicit category in err's unwrap tree.

Jump to

Keyboard shortcuts

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