errz

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCanceled           = E(Canceled)
	ErrUnknown            = E(Unknown)
	ErrInvalidArgument    = E(InvalidArgument)
	ErrDeadlineExceeded   = E(DeadlineExceeded)
	ErrNotFound           = E(NotFound)
	ErrAlreadyExists      = E(AlreadyExists)
	ErrPermissionDenied   = E(PermissionDenied)
	ErrResourceExhausted  = E(ResourceExhausted)
	ErrFailedPrecondition = E(FailedPrecondition)
	ErrAborted            = E(Aborted)
	ErrOutOfRange         = E(OutOfRange)
	ErrUnimplemented      = E(Unimplemented)
	ErrInternal           = E(Internal)
	ErrUnavailable        = E(Unavailable)
	ErrDataLoss           = E(DataLoss)
	ErrUnauthenticated    = E(Unauthenticated)
)
View Source
var DefaultFactory = Factory()

Functions

func As

func As(err error, target any) bool

func Factory

func Factory() *factory

func Is

func Is(err error, targets ...error) bool

func IsNot

func IsNot(err error, targets ...error) bool

func Join

func Join(errs ...error) error

func NotAs

func NotAs(err error, target any) bool

func Unwrap

func Unwrap(err error) error

Types

type Code added in v0.2.0

type Code int
const (
	// Canceled indicates that the operation was Canceled, typically by the caller.
	Canceled Code = 1

	// Unknown indicates that the operation failed for an Unknown reason.
	Unknown Code = 2

	// InvalidArgument indicates that client supplied an invalid argument.
	InvalidArgument Code = 3

	// DeadlineExceeded indicates that deadline expired before the operation could complete.
	DeadlineExceeded Code = 4

	// NotFound indicates that some requested entity (for example, a file or directory) was not found.
	NotFound Code = 5

	// AlreadyExists indicates that client attempted to create an entity (for example, a file or directory) that already exists.
	AlreadyExists Code = 6

	// PermissionDenied indicates that the caller doesn't have permission to execute the specified operation.
	PermissionDenied Code = 7

	// ResourceExhausted indicates that some resource has been exhausted.
	// For example, a per-user quota may be exhausted or the entire file system may be full.
	ResourceExhausted Code = 8

	// FailedPrecondition indicates that the system is not in a state required for the operation's execution.
	FailedPrecondition Code = 9

	// Aborted indicates that operation was Aborted by the system,
	// usually because of a concurrency issue such as a sequencer check failure or transaction abort.
	Aborted Code = 10

	// OutOfRange indicates that the operation was attempted past the valid range (for example, seeking past end-of-file).
	OutOfRange Code = 11

	// Unimplemented indicates that the operation isn't implemented, supported, or enabled in this service.
	Unimplemented Code = 12

	// Internal indicates that some invariants expected by the underlying system have been broken.
	// This code is reserved for serious errors.
	Internal Code = 13

	// Unavailable indicates that the service is currently Unavailable.
	// This is usually temporary, so clients can back off and retry idempotent operations.
	Unavailable Code = 14

	// DataLoss indicates that the operation has resulted in unrecoverable data loss or corruption.
	DataLoss Code = 15

	// Unauthenticated indicates that the request does not have valid authentication credentials for the operation.
	Unauthenticated Code = 16
)

func CodeOf

func CodeOf(err error) Code

CodeOf returns the error's status code if it is or wraps an *Error and [unknown] otherwise.

func (*Code) MarshalText added in v0.2.0

func (c *Code) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Code) String added in v0.2.0

func (c *Code) String() string

func (*Code) UnmarshalText added in v0.2.0

func (c *Code) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Error

type Error struct {
	// contains filtered or unexported fields
}

func E

func E(in ...any) *Error

func F

func F(format string, args ...any) *Error

func If added in v0.2.2

func If(err error, in ...any) *Error

func (*Error) As added in v0.1.1

func (e *Error) As(err error) bool

func (*Error) Code added in v0.2.0

func (e *Error) Code() Code

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is added in v0.1.1

func (e *Error) Is(targets ...error) bool

func (*Error) IsEmpty

func (e *Error) IsEmpty() bool

func (*Error) Location added in v0.2.0

func (e *Error) Location() *location

func (*Error) Message added in v0.2.0

func (e *Error) Message() string

func (*Error) Meta added in v0.2.0

func (e *Error) Meta() Metadata

func (*Error) StackTrace added in v0.2.0

func (e *Error) StackTrace() []runtime.Frame

func (*Error) String

func (e *Error) String() string

func (*Error) Timestamp added in v0.2.0

func (e *Error) Timestamp() *time.Time

func (*Error) Unwrap

func (e *Error) Unwrap() []error

func (*Error) With

func (e *Error) With(key string, value any) *Error

func (*Error) WithLocation

func (e *Error) WithLocation() *Error

func (*Error) WithTime

func (e *Error) WithTime() *Error

func (*Error) WithTrace

func (e *Error) WithTrace(skip int) *Error

func (*Error) Wrap

func (e *Error) Wrap(err error) *Error

type Metadata added in v0.2.1

type Metadata []detail

func (Metadata) Add added in v0.2.1

func (m Metadata) Add(key string, value any) Metadata

func (Metadata) Get added in v0.2.1

func (m Metadata) Get(key string) []any

func (Metadata) Has added in v0.2.1

func (m Metadata) Has(key string) bool

func (Metadata) String added in v0.2.1

func (m Metadata) String() string

Jump to

Keyboard shortcuts

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