Documentation
¶
Index ¶
- Constants
- Variables
- func ErrorStackTrace(err error) string
- func IsNoneErr(err error) bool
- func UnknownErr(err error) error
- func UnknownErrMsgf(msg string, args ...any) error
- func UnknownErrf(err error, msg string, args ...any) error
- func UnwrapErrStack(err error) (string, bool)
- func WrapErr(err error) error
- func WrapErrMulti(errs ...error) error
- func WrapErrf(err error, msg string, args ...any) error
- func WrapErrfCode(err error, code string, msg string, args ...any) error
- type MisoErr
- func (e *MisoErr) Cause() error
- func (e *MisoErr) Code() string
- func (e *MisoErr) Error() string
- func (e *MisoErr) HasCode() bool
- func (e *MisoErr) InternalMsg() string
- func (e *MisoErr) Is(target error) bool
- func (e *MisoErr) Msg() string
- func (e *MisoErr) New() error
- func (e *MisoErr) StackTrace() string
- func (e *MisoErr) Unwrap() error
- func (e *MisoErr) WithCode(code string) *MisoErr
- func (e *MisoErr) WithInternalMsg(msg string, args ...any) *MisoErr
- func (e *MisoErr) WithMsg(msg string) *MisoErr
- func (e *MisoErr) Wrap(cause error) error
- func (e *MisoErr) Wrapf(cause error, internalMsg string, args ...any) error
Constants ¶
Variables ¶
var (
Errf = NewErrf
)
Functions ¶
func ErrorStackTrace ¶
func UnknownErr ¶
Wrap an error to create new *MisoErr without any extra context.
This is almost equivalent to ErrUnknownError.Wrap(err)
If err is nil, nil is returned.
func UnknownErrMsgf ¶
Equivalent to ErrUnknownError.WithInternalMsg(msg, args...).
func UnwrapErrStack ¶
func WrapErr ¶
Wrap an error to create new *MisoErr with stacktrace.
If err is nil, nil is returned.
If err is *MisoErr, err is returned directly.
func WrapErrMulti ¶
Wrap multi errors to create new *MisoErr with stacktrace.
If err is nil, nil is returned.
If err is *MisoErr, err is returned directly.
Types ¶
type MisoErr ¶
type MisoErr struct {
// contains filtered or unexported fields
}
Miso Error.
Use NewErrf(...) to instantiate.
var ( ErrUnknownError *MisoErr = NewErrfCode(ErrCodeUnknownError, "Unknown Error") ErrNotPermitted *MisoErr = NewErrfCode(ErrCodeNotPermitted, "Not Permitted") ErrIllegalArgument *MisoErr = NewErrfCode(ErrCodeIllegalArgument, "Illegal Argument") ErrServerShuttingDown *MisoErr = NewErrfCode(ErrCodeServerShuttingDown, "Server Shutting Down") )
func NewErrfCode ¶
Create new *MisoErr with message and error code.
func (*MisoErr) InternalMsg ¶
func (*MisoErr) Is ¶
Implements *MisoErr Is check.
Returns true, if both are *MisoErr and the code matches.
WithInternalMsg always create new error, so we can basically reuse the same error created using 'miso.NewErrf(...).WithCode(...)'
var ErrIllegalArgument = miso.NewErrf(...).WithCode(...) var e1 = ErrIllegalArgument.WithInternalMsg(...) var e2 = ErrIllegalArgument.WithInternalMsg(...) errors.Is(e1, ErrIllegalArgument) errors.Is(e2, ErrIllegalArgument)