Categorygithub.com/lefinal/meh
modulepackage
2.0.0+incompatible
Repository: https://github.com/lefinal/meh.git
Documentation: pkg.go.dev

# README

meh

made-with-Go Go GitHub go.mod Go version GoReportCard example codecov GitHub issues GitHub code size in bytes

Mastery of Error Handling

Convenient error handling for Go using custom error containers and bubbling features.

Installation

In order to use this package, run:

go get github.com/lefinal/meh

# Packages

No description provided by the author
Package mehlog allows logging of meh.Error to zap.Logger.
No description provided by the author

# Functions

ApplyCode wraps the given error with the Code.
ApplyDetails wraps the given error with an ErrNeutral and the given Details.
ApplyStackTrace applies the current stack trace to the given error.
Cast tries to Cast the given error to *Error.
ErrorCode returns the first non ErrNeutral Code for the given error.
NewBadInputErr creates a new ErrBadInput with the given message and details.
NewBadInputErrFromErr creates a new ErrBadInput with the given error to be wrapped, message and details.
NewErrorUnwrapper allows iterating the given error from top to bottom level using ErrorUnwrapper.Next in a loop and getting the current level's error using ErrorUnwrapper.Current.
NewInternalErr creates a new ErrInternal with the given message and details.
NewInternalErrFromErr creates a new ErrInternal with the given error to be wrapped, message and details.
NewNotFoundErr creates a new ErrNotFound with the given message and details.
NewNotFoundErrFromErr creates a new ErrNotFound with the given error to be wrapped, message and details.
ToMap returns the details of the given error as a key-value map with appended enhanced information regarding the error itself (Error.Code to MapFieldErrorCode and the Error.Error-message to MapFieldErrorMessage).
Wrap wraps the given error with an ErrNeutral, the message and details.

# Constants

ErrBadInput is used when submitted data was invalid.
ErrInternal is used for basic internal errors.
ErrNeutral is used mainly for wrapping in order to not change the Code.
ErrNotFound is used when requested resources where not found.
ErrUnexpected is the default error that is used when no other Code is specified.
Field names for usage in ToMap.
Field names for usage in ToMap.

# Structs

Error is the container for any relevant error information that needs to be kept when bubbling.
ErrorUnwrapper is used for iterating over the recursive structure of wrapped errors in Error.WrappedErr.
StackTrace holds an errors.StackTrace as well as a formatted stack trace for usage in logging.

# Type aliases

Code is the type of error in Error.
Details are optionally provided error details in Error.Details that are used for easier debugging and error locating.