errcat

package
v2.18.0-pro Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK           = Category(iota)
	User         // User made an error
	Config       // Errors in config.yml, extensions, or kubeconfig
	NoDaemonLogs // Other error generated in the CLI process, so no use pointing the user to logs
	Unknown      // Something else. Consult the logs
)

Variables

This section is empty.

Functions

func FromResult

func FromResult(r *common.Result) error

func ToResult

func ToResult(err error) *common.Result

Types

type Category

type Category int

The Category is used for categorizing errors so that we can know when to point the user to the logs or not.

func GetCategory

func GetCategory(err error) Category

GetCategory returns the error category for a categorized error, OK for nil, and Unknown for other errors.

func (Category) New

func (c Category) New(untypedErr any) error

New creates a new categorized error based in its argument. The argument can be an error or a string. If it isn't, it will be converted to a string using its '%v' formatter.

func (Category) Newf

func (c Category) Newf(format string, a ...any) error

Newf creates a new categorized error based on a format string with arguments. The error is created using fmt.Errorf() so using '%w' is relevant for error arguments.

Jump to

Keyboard shortcuts

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