errors

package
v0.0.0-...-24f16ac Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package errors provides the standard library's errors package with additional functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true.

func Is

func Is(err, target error) bool

Is reports whether any error in err's chain matches target.

func Join

func Join(err ...error) error

Join returns an error that wraps the given errors. Any nil error values are discarded. Join returns nil if every value in errs is nil. The error formats as the concatenation of the strings obtained by calling the Error method of each element of errs, with a newline between each string. A non-nil error returned by Join implements the Unwrap() []error method.

func New

func New(text string) error

New returns an error that formats as the given text.

func Unwrap

func Unwrap(err error) error

Unwrap returns the result of calling the Unwrap method on err, if err's type contains an Unwrap method returning error. Otherwise, Unwrap returns nil.

Types

type Category

type Category uint32

Category represents the category of the error.

const (
	// CatUnknown represents an unknown category. This should not be used.
	CatUnknown Category = Category(pb.ErrorCategory_EC_UNKNOWN) // Unknown
	// CatRequest represents an error that is caused by the request being incorrect.
	CatRequest Category = Category(pb.ErrorCategory_EC_REQUEST) // Request
	// CatSafety represents an error that is caused by a safety issue.
	CatSafety Category = Category(pb.ErrorCategory_EC_SAFETY) // Safety
	// CatPermission represents an error that is caused by a permission issue.
	CatPermission Category = Category(pb.ErrorCategory_EC_PERMISSION) // Permission
	// CatResourceExhausted represents an error that is caused by a resource being exhausted.
	CatResourceExhausted Category = Category(pb.ErrorCategory_EC_RESOURCE_EXHAUSTED) // ResourceExhausted
	// CatInternal represents an error that is caused by an internal issue.
	CatInternal Category = Category(pb.ErrorCategory_EC_INTERNAL) // Internal
)

func (Category) Category

func (c Category) Category() string

func (Category) Code

func (c Category) Code() codes.Code

Code returns the gRPC status code for the category.

func (Category) String

func (i Category) String() string

type Error

type Error = errors.Error

Error is our base error type.

func E

func E(ctx context.Context, c Category, t Type, msg error, options ...Option) Error

E creates a new Error with the given category, type, message, and arguments. It will automatically redact any secrets from the error message unless WithNoSecretDetection is passed.

type Option

type Option func(newOptions) newOptions

Option is a function that modifies the options.

func WithNoSecretDetection

func WithNoSecretDetection() Option

WithNoSecretDetection returns an Option that will prevent secret detection from scrubbing the error message.

type Type

type Type uint16

Type represents the type of the error.

const (
	// TypeUnknown represents an unknown type.
	TypeUnknown Type = Type(pb.ErrorType_ET_UNKNOWN) // Unknown

	// TypeBadRequest represents a bad request error.
	TypeBadRequest Type = Type(pb.ErrorType_ET_BAD_REQUEST) // BadRequest

	// TypeDeadTimer represents that a resource is restricted by a dead timer. Until that
	// timer expires, the resource cannot be accessed for this use.
	TypeDeadTimer Type = Type(pb.ErrorType_ET_DEAD_TIMER) // DeadTimer
	// TypeClusterHealth represents that the cluster is unhealthy and cannot be accessed.
	TypeClusterHealth Type = Type(pb.ErrorType_ET_CLUSTER_HEALTH) // ClusterHealth

	// TypePermissionDenied represents that the user does not have permission to access the resource.
	TypePermissionDenied Type = Type(pb.ErrorType_ET_PERMISSION_DENIED) // PermissionDenied
)

func (Type) String

func (i Type) String() string

func (Type) Type

func (t Type) Type() string

Directories

Path Synopsis
Package example is a reverse proxy.
Package example is a reverse proxy.

Jump to

Keyboard shortcuts

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