modulepackage
0.0.0-20240702051036-0e696c849b5f
Repository: https://github.com/domonda/go-errs.git
Documentation: pkg.go.dev
# README
go-errs
Go 1.13 compatible error wrapping with call stacks and function parameters
# Packages
No description provided by the author
# Functions
As returns all errors of type T in the wrapping tree of err.
AsError converts any type to an error without wrapping it.
AsErrorWithDebugStack converts any type to an error and if not nil wraps it with debug.Stack() after a newline.
DontLog wraps the passed error as LogDecisionMaker so that ShouldLog returns false.
Errorf wraps the result of fmt.Errorf with the current call stack.
Has is a shortcut for errors.As when the target error value is not needed.
IsContextCanceled checks if the context Done channel is closed and if the context error unwraps to context.Canceled.
IsContextDeadlineExceeded checks if the context Done channel is closed and if the context error unwraps to context.DeadlineExceeded.
IsContextDone checks if the context Done channel is closed.
IsContextError returns true if err unwraps to context.Canceled or context.DeadlineExceeded.
IsErrNotFound returns true if the passed error unwraps to, or is ErrNotFound, sql.ErrNoRows, or os.ErrNotExist.
IsOtherThanErrNotFound returns true if the passed error is not nil and does not unwrap to, or is ErrNotFound, sql.ErrNoRows, or os.ErrNotExist.
IsType returns if err or any unwrapped error is of the type of the passed ref error.
LogFunctionCall using FormatFunctionCall if logger is not nil.
LogPanicWithFuncParams recovers any panic, converts it to an error wrapped with the callstack of the panic and the passed function parameter values and prints it with the prefix "LogPanicWithFuncParams: " to the passed Logger.
New returns a new error with the passed text wrapped with the current call stack.
RecoverAndLogPanicWithFuncParams recovers any panic, converts it to an error wrapped with the callstack of the panic and the passed function parameter values and prints it with the prefix "RecoverAndLogPanicWithFuncParams: " to the passed Logger.
RecoverPanicAsError recovers any panic, converts it to an error wrapped with the callstack of the panic and assigns it to the result error.
RecoverPanicAsErrorWithFuncParams recovers any panic, converts it to an error wrapped with the callstack of the panic and the passed function parameter values and assigns it to the result error.
ReplaceErrNotFound returns the passed replacement error if IsErrNotFound(err) returns true, meaning that all (optionally wrapped) ErrNotFound, sql.ErrNoRows, os.ErrNotExist errors get replaced.
Root unwraps err recursively and returns the root error.
ShouldLog checks if the passed error unwraps as a LogDecisionMaker and returns the result of its ShouldLog method.
Type indicates if err is not nil and it or any unwrapped error is of the type T.
UnwrapCallStack unwraps callstack information from err and returns the first non callstack wrapper error.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WrapWithCallStack wraps an error with the current call stack.
WrapWithCallStackSkip wraps an error with the current call stack skipping skip stack frames.
No description provided by the author
No description provided by the author
# Constants
ErrNotFound is an universal error returned in case that a requested resource could not be found.
# Variables
FormatFunctionCall formats a function call in pseudo syntax using the PrintForCallStack method of params that implement the CallStackPrintable interface or github.com/domonda/go-pretty to format params that don't implement CallStackPrintable.
TrimFilePathPrefix will be trimmed from the beginning of every call-stack file-path.
# Interfaces
CallStackPrintable can be implemented to customize the printing of the implementation's data in an error call stack output.
LogDecisionMaker can be implemented by errors to decide if they should be logged.
Logger is an interface that can be implemented to log errors.
# Type aliases
Sentinel implements the error interface for a string and is meant to be used to declare const sentinel errors.