Documentation
¶
Index ¶
- Variables
- func BadRequest(err error) *errBadRequestWrap
- func BadRequestPrefix(preamble string, err error) *errBadRequestPreamble
- func BadRequestf(fmt string, args ...any) *errBadRequestWrap
- func Deferred(err *error, ef func() error)
- func DeferredChan(ch chan<- error, f func() error)
- func DeferredChanError(err *error, ch <-chan error)
- func DeferredCloseAndRename(err *error, c io.Closer, oldpath, newpath string)
- func DeferredCloser(err *error, c io.Closer)
- func DeferredFlusher(err *error, f Flusher)
- func DeferredYieldCloser[T any](yield func(T, error) bool, c io.Closer)
- func ErrorWithStackf(f string, values ...interface{}) (err error)
- func Errorf(f string, values ...interface{}) (err error)
- func Implement() (err error)
- func Is(err, target error) bool
- func IsAny(err error, ises ...FuncIs) bool
- func IsAsNilOrWrapf(err error, target error, format string, values ...any) (out error)
- func IsBadRequest(err error) bool
- func IsBrokenPipe(err error) bool
- func IsEOF(err error) bool
- func IsErrFalse(err error) bool
- func IsErrTrue(err error) bool
- func IsErrno(err error, targets ...syscall.Errno) (ok bool)
- func IsExist(err error) bool
- func IsNetTimeout(err error) (ok bool)
- func IsNotExist(err error) bool
- func IsNotNilAndNotEOF(err error) bool
- func IsStopIteration(err error) bool
- func IsTooManyOpenFiles(err error) bool
- func IterWrapped[T any](err error) iter.Seq2[T, error]
- func Join(es ...error) error
- func MakeContext(in ConTeXT.Context) *context
- func MakeContextDefault() *context
- func MakeErrStopIteration() error
- func MakeMulti(errs ...error) (em *multi)
- func NewNormal(v string) errNormal
- func PanicIfError(err interface{})
- func PrintHelpful(printer interfaces.Printer, helpful Helpful)
- func RunChildContextWithPrintTicker(parentContext Context, runFunc func(Context), printFunc func(time.Time), ...) (err error)
- func RunContextWithPrintTicker(context Context, runFunc func(Context), printFunc func(time.Time), ...) (err error)
- func SetTesting()
- func Wrap(in error) error
- func WrapExcept(in error, except ...error) (err error)
- func WrapExceptAsNil(in error, except ...error) (err error)
- func WrapN(n int, in error) (err error)
- func WrapSkip(skip int, in error) (err *stackWrapError)
- func Wrapf(in error, f string, values ...any) error
- type Context
- type ContextWithEnv
- type ErrBadRequest
- type Flusher
- type Func
- type FuncIs
- type FuncWithStackInfo
- type Helpful
- type Multi
- type Retryable
- type RetryableContext
- type Signal
- type StackFrame
- func (si StackFrame) Errorf(f string, values ...any) (err error)
- func (si StackFrame) FileNameLine() string
- func (frame StackFrame) String() string
- func (frame StackFrame) StringLogLine() string
- func (si StackFrame) StringNoFunctionName() string
- func (frame StackFrame) Wrap(in error) (err error)
- func (si StackFrame) Wrapf(in error, f string, values ...any) (err error)
- type StackTracer
- type WaitGroup
- type WithStackInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ( As = errors.As Unwrap = errors.Unwrap )
View Source
var ( ErrNotImplemented = New("not implemented") ErrNotSupported = New("not supported") )
View Source
var ( ErrFalse = New("false") ErrTrue = New("true") ErrStopIteration = New("stop iteration") )
View Source
var New = xerrors.New
Functions ¶
func BadRequest ¶
func BadRequest(err error) *errBadRequestWrap
func BadRequestPrefix ¶
func BadRequestf ¶
func DeferredChan ¶
func DeferredChanError ¶
func DeferredCloseAndRename ¶
func DeferredCloser ¶
func DeferredFlusher ¶
func DeferredYieldCloser ¶
func ErrorWithStackf ¶
func IsAsNilOrWrapf ¶
func IsBadRequest ¶
func IsBrokenPipe ¶
func IsErrFalse ¶
func IsNetTimeout ¶
func IsNotExist ¶
func IsNotNilAndNotEOF ¶
func IsStopIteration ¶
func IsTooManyOpenFiles ¶
func MakeContext ¶
func MakeContextDefault ¶
func MakeContextDefault() *context
func MakeErrStopIteration ¶
func MakeErrStopIteration() error
func NewNormal ¶
func NewNormal(v string) errNormal
TODO refactor NewNormal into something that combines helpful and stack trace
func PanicIfError ¶
func PanicIfError(err interface{})
func PrintHelpful ¶
func PrintHelpful(printer interfaces.Printer, helpful Helpful)
func SetTesting ¶
func SetTesting()
func WrapExcept ¶
wrap the error with stack info unless it's one of the provided `except` errors, in which case return that bare error
func WrapExceptAsNil ¶
wrap the error with stack info unless it's one of the provided `except` errors, in which case return nil.
Types ¶
type Context ¶
type Context interface {
ConTeXT.Context
Cause() error
Continue() bool
ContinueOrPanicOnDone()
SetCancelOnSIGINT()
SetCancelOnSIGHUP()
SetCancelOnSignals(signals ...os.Signal)
Run(f func(Context)) error
// `After` runs a function after the context is complete (regardless of any
// errors). `After`s are run in the reverse order of when they are called, like
// defers but on a whole-program level.
After(f func() error)
AfterWithContext(f func(Context) error)
// `Must` executes a function even if the context has been cancelled. If the
// function returns an error, `Must` cancels the context and offers a heartbeat to
// panic. It is meant for defers that must be executed, like closing files,
// flushing buffers, releasing locks.
Must(f func() error)
MustWithContext(f func(Context) error)
MustClose(closer io.Closer)
MustFlush(flusher Flusher)
Cancel()
CancelWithError(err error)
CancelWithErrorAndFormat(err error, f string, values ...any)
CancelWithErrorf(f string, values ...any)
CancelWithBadRequestError(err error)
CancelWithBadRequestf(f string, values ...any)
CancelWithNotImplemented()
}
type ContextWithEnv ¶
type ErrBadRequest ¶
type ErrBadRequest interface {
IsBadRequest()
}
type FuncIs ¶
func MakeIsErrno ¶
type FuncWithStackInfo ¶
type FuncWithStackInfo struct {
Func
StackFrame
}
type Retryable ¶
type Retryable interface {
GetRetryableError() Retryable
Recover(RetryableContext, error)
}
type RetryableContext ¶
type RetryableContext interface {
Context
Retry()
}
type StackFrame ¶
type StackFrame struct {
Package string
Function string
Filename string
RelFilename string
Line int
// contains filtered or unexported fields
}
func MakeStackFrame ¶
func MakeStackFrame(skip int) (si StackFrame, ok bool)
func MakeStackFrameFromFrame ¶
func MakeStackFrameFromFrame(runtimeFrame runtime.Frame) (frame StackFrame)
func MakeStackFrames ¶
func MakeStackFrames(skip, count int) (frames []StackFrame)
func MustStackFrame ¶
func MustStackFrame(skip int) StackFrame
func (StackFrame) FileNameLine ¶
func (si StackFrame) FileNameLine() string
func (StackFrame) String ¶
func (frame StackFrame) String() string
func (StackFrame) StringLogLine ¶
func (frame StackFrame) StringLogLine() string
func (StackFrame) StringNoFunctionName ¶
func (si StackFrame) StringNoFunctionName() string
func (StackFrame) Wrap ¶
func (frame StackFrame) Wrap(in error) (err error)
If the frame is non-zero, return a wrapped error. Otherwise return the input error unwrapped.
type StackTracer ¶
TODO refactor / remove?
type WaitGroup ¶
func MakeWaitGroupParallel ¶
func MakeWaitGroupParallel() WaitGroup
func MakeWaitGroupSerial ¶
func MakeWaitGroupSerial() WaitGroup
type WithStackInfo ¶
type WithStackInfo[T any] struct { Contents T StackFrame }
Click to show internal directories.
Click to hide internal directories.