Documentation ¶
Index ¶
- func As(err error, target any) bool
- func Is(err error, target error) bool
- func IsGonatusError(err error) bool
- func Join(errs ...error) error
- func New(conf ErrorConf) error
- func NewMisappError(src gonatus.Gobjecter, msg string) error
- func NewNilError(src gonatus.Gobjecter, level ErrorLevel, msg string) error
- func NewNotFoundError(src gonatus.Gobjecter, level ErrorLevel, msg string) error
- func NewNotImplError(src gonatus.Gobjecter) error
- func NewSrcWrapper(src gonatus.Gobjecter, err error) error
- func NewStateError(src gonatus.Gobjecter, level ErrorLevel, msg string) error
- func NewUnknownError(src gonatus.Gobjecter) error
- func NewValueError(src gonatus.Gobjecter, level ErrorLevel, msg string) error
- func OfType(err error, errType ErrorType) bool
- func Serialize(err error) gonatus.Conf
- func Traceback(err error) string
- func Unwrap(err error) error
- func Wrap(msg string, errType ErrorType, wrapped error) error
- type ErrorConf
- type ErrorLevel
- type ErrorType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶
Calls the standard As function. As finds the first error in err's tree that matches target, and if one is found, sets target to that error value.
Parameters:
- err - error to search in,
- target - target error.
Returns:
- true if a match is found, false otherwise.
func Is ¶
Calls the standard Is function. Is reports whether any error in err's tree matches target.
Parameters:
- err - error to search in,
- target - target error.
Returns:
- true if a match is found, false otherwise.
func IsGonatusError ¶
Checks if the given error is a Gonatus error.
Parameters:
- err - error to check.
Returns:
- true if the error is a Gonatus error, false otherwise.
func Join ¶
Calls the standard Join function. Creates an error that wraps the given errors.
Parameters:
- errs - any number of errors to join.
Returns:
- new error.
func New ¶
Creates a new Gonatus error.
Parameters:
- conf - serialized error.
Returns:
- created error.
func NewMisappError ¶
Creates a new source wrapper with a missapplication error.
Parameters:
- src - source of the error.
Returns:
- created error.
func NewNilError ¶
func NewNilError(src gonatus.Gobjecter, level ErrorLevel, msg string) error
Creates a new source wrapper with a nil error.
Parameters:
- src - source of the error.
Returns:
- created error.
func NewNotFoundError ¶
func NewNotFoundError(src gonatus.Gobjecter, level ErrorLevel, msg string) error
Creates a new source wrapper with a not found error.
Parameters:
- src - source of the error.
Returns:
- created error.
func NewNotImplError ¶
Creates a new source wrapper with a not implemented error.
Parameters:
- src - source of the error.
Returns:
- created error.
func NewSrcWrapper ¶
Wraps the given error with a wrapper containing information about the object which caused it. If the error level is below the seriousness threshold, the text of the wrapper will be empty.
Parameters:
- src - Gobject which called the function,
- err - error to wrap.
Returns:
- created error.
func NewStateError ¶
func NewStateError(src gonatus.Gobjecter, level ErrorLevel, msg string) error
Creates a new source wrapper with a state error.
Parameters:
- src - source of the error.
Returns:
- created error.
func NewUnknownError ¶
Creates a new source wrapper with an unknown error.
Parameters:
- src - source of the error.
Returns:
- created error.
func NewValueError ¶
func NewValueError(src gonatus.Gobjecter, level ErrorLevel, msg string) error
Creates a new source wrapper with a value error.
Parameters:
- src - source of the error.
Returns:
- created error.
func OfType ¶
Checks if the given error is of the given error type.
Parameters:
- err - error to check,
- errType - type to check.
Returns:
- true if the error is of the type, false otherwise.
func Traceback ¶
Acquires a traceback of the given error. If no traceback was created, message "No traceback." is returned.
Parameters:
- err - error to trace.
Returns:
- traceback.
Types ¶
type ErrorConf ¶
type ErrorConf struct { Type ErrorType `json:"type"` Level ErrorLevel `json:"level,omitempty"` Msg string `json:"msg"` Traceback string `json:"traceback,omitempty"` Wrapped []ErrorConf `json:"wrapped,omitempty"` }
type ErrorLevel ¶
type ErrorLevel int
Seriousness of the error. The values are synchronized with the Slog library.
const ( LevelWrapper ErrorLevel = -8 // Not even an error, the actual one is wrapped inside. LevelInfo ErrorLevel = 0 // Non-standard situation has occurred, but program continues normally. LevelWarning ErrorLevel = 4 // Something did not work out, alternative approach used. LevelError ErrorLevel = 8 // Normal error level. LevelFatal ErrorLevel = 12 // Most serious error, impossible to continue. )
type ErrorType ¶
type ErrorType string
Type of the error.
const ( TypeNA ErrorType = "UndeterminedError" // The type of the error was not specified TypeUnknown ErrorType = "UnknownError" // The program got into a state which should theoretically be impossible. TypeNil ErrorType = "NilError" // Value missing where expected. TypeValue ErrorType = "ValueError" // Value present but not valid. TypeState ErrorType = "StateError" // The program got into an incorrect state. TypeNotFound ErrorType = "NotFoundError" // The required value could not be found. TypeMisapp ErrorType = "MissapplicationError" // The function was incorrectly used by the user. TypeNotImpl ErrorType = "NotImplementedError" // The function is not implemented by this object. )