errors

package
v0.0.0-...-3525705 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Err400BadRequest          = newHttpError(hs.Code400BadRequest)
	Err405MethodNotAllowed    = newHttpError(hs.Code405MethodNotAllowed)
	Err409Conflict            = newHttpError(hs.Code409Conflict)
	Err422UnprocessableEntity = newHttpError(hs.Code409Conflict)
	Err499ClientClosedRequest = newHttpError(hs.Code499ClientClosedRequest)
	Err500InternalServerError = newHttpError(hs.Code500InternalServerError)
	Err501NotImplemented      = newHttpError(hs.Code501NotImplemented)
)
View Source
var (
	As     = errors.As
	Unwrap = errors.Unwrap
)
View Source
var ErrExists = New("exists")

Functions

func BadRequest

func BadRequest(err error) error

func BadRequestWrapf

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

func BadRequestf

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

func CancelWithNotImplemented

func CancelWithNotImplemented(ctx interfaces.ActiveContext)

func ContextCancelWith499ClientClosedRequest

func ContextCancelWith499ClientClosedRequest(ctx interfaces.ActiveContext)

func ContextCancelWithBadRequestError

func ContextCancelWithBadRequestError(ctx interfaces.ActiveContext, err error)

func ContextCancelWithBadRequestf

func ContextCancelWithBadRequestf(
	ctx interfaces.ActiveContext,
	format string,
	values ...any,
)

func ContextCancelWithError

func ContextCancelWithError(ctx interfaces.ActiveContext, err error)

func ContextCancelWithErrorAndFormat

func ContextCancelWithErrorAndFormat(
	ctx interfaces.ActiveContext,
	err error,
	format string,
	values ...any,
)

func ContextCancelWithErrorf

func ContextCancelWithErrorf(
	ctx interfaces.ActiveContext,
	format string,
	values ...any,
)

func ContextCloseAfter

func ContextCloseAfter(ctx interfaces.ActiveContext, closer io.Closer)

func ContextContinueOrPanic

func ContextContinueOrPanic(ctx interfaces.ActiveContext)

func ContextFlushAfter

func ContextFlushAfter(ctx interfaces.ActiveContext, closer io.Closer)

func ContextMustClose

func ContextMustClose(ctx interfaces.ActiveContext, closer io.Closer)

func ContextMustFlush

func ContextMustFlush(ctx interfaces.ActiveContext, flusher Flusher)

func ContextSetCancelOnSIGHUP

func ContextSetCancelOnSIGHUP(ctx Context)

func ContextSetCancelOnSIGINT

func ContextSetCancelOnSIGINT(ctx Context)

func ContextSetCancelOnSIGTERM

func ContextSetCancelOnSIGTERM(ctx Context)

func Deferred

func Deferred(
	err *error,
	ef func() error,
)

func DeferredCloseAndRename

func DeferredCloseAndRename(err *error, c io.Closer, oldpath, newpath string)

func DeferredCloser

func DeferredCloser(
	err *error,
	closer io.Closer,
)

func DeferredFlusher

func DeferredFlusher(
	err *error,
	f Flusher,
)

func DeferredRecover

func DeferredRecover(err *error)

func DeferredYieldCloser

func DeferredYieldCloser[T any](
	yield func(T, error) bool,
	closer io.Closer,
)

func ErrorWithStackf

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

func Errorf

func Errorf(format string, args ...any) (err error)

func Is

func Is(err, target error) bool

func Is400BadRequest

func Is400BadRequest(err error) bool

func Is499ClientClosedRequest

func Is499ClientClosedRequest(err error) bool

func IsAny

func IsAny(err error, funcTargets ...FuncIs) bool

func IsBrokenPipe

func IsBrokenPipe(err error) bool

func IsEOF

func IsEOF(err error) bool

func IsErrNotFound

func IsErrNotFound(err error) bool

func IsErrno

func IsErrno(err error, targets ...syscall.Errno) (ok bool)

func IsExist

func IsExist(err error) bool

func IsHTTPError

func IsHTTPError(target error, statusCode hs.Code) bool

func IsNetTimeout

func IsNetTimeout(err error) (ok bool)

func IsNotExist

func IsNotExist(err error) bool

func IsNotNilAndNotEOF

func IsNotNilAndNotEOF(err error) bool

TODO remove

func IsReadlinkInvalidArgument

func IsReadlinkInvalidArgument(err error) bool

func IsSentinel

func IsSentinel(err, target error) bool

func IsStopIteration

func IsStopIteration(err error) bool

func IsTooManyOpenFiles

func IsTooManyOpenFiles(err error) bool

func IsTyped

func IsTyped[DISAMB any](err error) bool

func IsWithTimeout

func IsWithTimeout(err, target error, timeout time.Duration) bool

func Join

func Join(es ...error) error

func MakeContext

func MakeContext(in ConTeXT.Context) *context

func MakeContextDefault

func MakeContextDefault() *context

func MakeErrNotFound

func MakeErrNotFound(value interfaces.Stringer) error

func MakeErrNotFoundString

func MakeErrNotFoundString(s string) error

func MakeErrStopIteration

func MakeErrStopIteration() error

func Must

func Must(funk FuncErr)

func PanicIfError

func PanicIfError(err any)

func PrintHelpful

func PrintHelpful(printer interfaces.Printer, helpful Helpful)

func PrintStackTracerIfNecessary

func PrintStackTracerIfNecessary(
	printer interfaces.Printer,
	name string,
	err error,
	_ ...any,
)

func RunChildContextWithPrintTicker

func RunChildContextWithPrintTicker(
	parentContext Context,
	runFunc func(Context),
	printFunc func(time.Time),
	duration time.Duration,
) (err error)

func RunContextWithPrintTicker

func RunContextWithPrintTicker(
	context Context,
	runFunc func(Context),
	printFunc func(time.Time),
	duration time.Duration,
) (err error)

func WithoutStack

func WithoutStack(err error) error

func Wrap

func Wrap(err error) error

func WrapExceptSentinel

func WrapExceptSentinel(in error, except ...error) (err error)

Wrap the error with stack info unless it's one of the provided `except` errors, in which case return that bare error. Direct value comparison is performed (`in == except`) rather than errors.Is.

func WrapExceptSentinelAsNil

func WrapExceptSentinelAsNil(in error, except ...error) (err error)

Wrap the error with stack info unless it's one of the provided `except` errors, in which case return nil. Direct value comparison is performed (`in == except`) rather than errors.Is.

func WrapSkip

func WrapSkip(
	skip int,
	err error,
) error

func Wrapf

func Wrapf(err error, format string, values ...any) error

Types

type Context

type Context interface {
	interfaces.ActiveContext
	CauseWithStackFrames() (error, []stack_frame.Frame)
	Run(func(Context)) error

	// TODO extricate from *context and turn into generic function
	SetCancelOnSignals(signals ...os.Signal)
}

type ErrNotFound

type ErrNotFound string

func (ErrNotFound) Error

func (err ErrNotFound) Error() string

func (ErrNotFound) Is

func (err ErrNotFound) Is(target error) (ok bool)

type ErrorsIs

type ErrorsIs interface {
	Is(error) bool
}

type Flusher

type Flusher interface {
	Flush() error
}

type FuncContext

type FuncContext = interfaces.FuncActiveContext

func MakeFuncContextFromFuncErr

func MakeFuncContextFromFuncErr(in FuncErr) FuncContext

func MakeFuncContextFromFuncNil

func MakeFuncContextFromFuncNil(in FuncNil) FuncContext

type FuncErr

type FuncErr = func() error

func MakeFuncErrFromFuncNil

func MakeFuncErrFromFuncNil(in FuncNil) FuncErr

type FuncIs

type FuncIs func(error) bool

func MakeIsErrno

func MakeIsErrno(targets ...syscall.Errno) FuncIs

type FuncNil

type FuncNil = func()

type FuncWithStackInfo

type FuncWithStackInfo struct {
	FuncErr
	stack_frame.Frame
}

type Group

type Group []error

func (Group) Error

func (group Group) Error() string

func (Group) Len

func (group Group) Len() int

func (Group) Unwrap

func (group Group) Unwrap() []error

type GroupBuilder

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

func MakeGroupBuilder

func MakeGroupBuilder(
	errs ...error,
) (groupBuilder *GroupBuilder)

TODO consider making a pool and return a repool func on construction

func (*GroupBuilder) Add

func (groupBuilder *GroupBuilder) Add(err error)

func (*GroupBuilder) Empty

func (groupBuilder *GroupBuilder) Empty() (ok bool)

func (*GroupBuilder) GetError

func (groupBuilder *GroupBuilder) GetError() error

func (*GroupBuilder) Len

func (groupBuilder *GroupBuilder) Len() int

func (*GroupBuilder) Reset

func (groupBuilder *GroupBuilder) Reset()

type Helpful

type Helpful interface {
	error
	GetErrorCause() []string
	GetErrorRecovery() []string
}

func WithHelp

func WithHelp(
	err error,
	cause []string,
	recovery []string,
) Helpful

type Signal

type Signal struct {
	os.Signal
}

func (Signal) Error

func (err Signal) Error() string

func (Signal) Is

func (err Signal) Is(target error) bool

type Typed

type Typed[DISAMB any] interface {
	error
	GetErrorType() DISAMB
}

func New

func New(text string) Typed[string]

func NewWithType

func NewWithType[DISAMB any](text string) Typed[DISAMB]

func WrapWithType

func WrapWithType[DISAMB any](err error) Typed[DISAMB]

type UnwrapMany

type UnwrapMany = interfaces.ErrorManyUnwrapper

type UnwrapOne

type UnwrapOne = interfaces.ErrorOneUnwrapper

type WaitGroup

type WaitGroup interface {
	Do(FuncErr) bool
	DoAfter(FuncErr)
	GetError() error
}

func MakeWaitGroupParallel

func MakeWaitGroupParallel() WaitGroup

func MakeWaitGroupSerial

func MakeWaitGroupSerial() WaitGroup

type WithStackInfo

type WithStackInfo[T any] struct {
	Contents T
	stack_frame.Frame
}

Source Files

  • context.go
  • context_sentinels.go
  • deferred.go
  • group.go
  • group_builder.go
  • helpful.go
  • http.go
  • http_util.go
  • interfaces.go
  • is.go
  • main.go
  • main_release.go
  • normal.go
  • sentinels.go
  • signal.go
  • wait_group_parallel.go
  • wait_group_serial.go
  • wrapped_helpful.go
  • wrapped_without_stack.go

Jump to

Keyboard shortcuts

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