Documentation ¶
Overview ¶
Package errors is replacement package for standard errors package. It attaches error code and stack information to the error object.
Index ¶
- Constants
- Variables
- func Error(e error) error
- func Errorc(c Code, msg string) error
- func Errorcf(c Code, f string, args ...interface{}) error
- func Errorf(f string, args ...interface{}) error
- func FindCause(err error, cb func(err error) bool) error
- func Is(err, target error) bool
- func IsCritical(e error) bool
- func IsCriticalCode(c Code) bool
- func New(msg string) error
- func NewBase(c Code, msg string) *codedError
- func ToString(e error) string
- func Unwrap(err error) error
- func WithCode(err error, c Code) error
- func WithStack(e error) error
- func Wrap(e error, msg string) error
- func Wrapc(e error, c Code, msg string) error
- func Wrapcf(e error, c Code, f string, args ...interface{}) error
- func Wrapf(e error, f string, args ...interface{}) error
- type Code
- type ErrorCoder
- type ErrorWithStack
- type StackTracer
- type Unwrapper
Constants ¶
View Source
const ( CriticalUnknownError = CodeCritical + iota CriticalIOError CriticalFormatError CriticalHashError CriticalRerunError )
View Source
const CodeSegment = 1000
Variables ¶
View Source
var ( ErrUnknown = NewBase(UnknownError, "UnknownError") ErrIllegalArgument = NewBase(IllegalArgumentError, "IllegalArgument") ErrInvalidState = NewBase(InvalidStateError, "InvalidState") ErrUnsupported = NewBase(UnsupportedError, "Unsupported") ErrNotFound = NewBase(NotFoundError, "NotFound") ErrInvalidNetwork = NewBase(InvalidNetworkError, "InvalidNetwork") ErrTimeout = NewBase(TimeoutError, "Timeout") ErrExecutionFail = NewBase(ExecutionFailError, "ExecutionFail") ErrInterrupted = NewBase(InterruptedError, "Interrupted") )
Functions ¶
func Error ¶ added in v1.3.0
Error returns wrapped error providing formatter to show error code and stacks properly.
func IsCritical ¶
func IsCriticalCode ¶
Types ¶
type Code ¶
type Code int
const ( CodeSCORE Code = iota * CodeSegment CodeGeneral CodeService CodeConsensus CodeNetwork CodeBlock CodeServer CodeCritical )
const ( Success Code = 0 UnknownError Code = CodeGeneral + iota IllegalArgumentError UnsupportedError InvalidStateError NotFoundError InvalidNetworkError TimeoutError ExecutionFailError InterruptedError )
type ErrorCoder ¶
func CoderOf ¶
func CoderOf(e error) (ErrorCoder, bool)
type ErrorWithStack ¶ added in v1.3.0
type ErrorWithStack interface { error StackTracer }
type StackTracer ¶ added in v1.3.0
type StackTracer interface {
StackTrace() errors.StackTrace
}
func StackTracerOf ¶ added in v1.3.0
func StackTracerOf(e error) (StackTracer, bool)
Click to show internal directories.
Click to hide internal directories.