Documentation ¶
Index ¶
- func AddExtrasToError(err error, _extras map[string]interface{}) error
- func AddTagsToError(err error, _tags map[string]string) error
- func Code(err error, defaultCode int) (code int)
- func DeepestCause(err error) error
- func Extras(err error) (cumulativeExtras map[string]interface{})
- func Fatal(err error) (isFatal bool)
- func Ignore(err error) bool
- func NewError(_msg string, _cause error, _fatal bool) error
- func NewErrorToIgnore(_msg string, _cause error) error
- func NewErrorWithCode(_msg string, code int, _cause error) error
- func NewErrorWithExtras(_msg string, _cause error, _fatal bool, _extras map[string]interface{}) error
- func NewErrorWithTags(_msg string, _cause error, _fatal bool, _tags map[string]string) error
- func NewErrorWithTagsAndExtras(_msg string, _cause error, _fatal bool, _tags map[string]string, ...) error
- func PrintStackTrace(err error)
- func Stacktrace(err error) string
- func Tags(err error) (cumulativeTags map[string]string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddExtrasToError ¶
AddExtrasToError checks if the input error implements a causer interface. If it does, it checks if the Cause is of internal type *rung. When this check also passes, it adds the input _extras to the existing extras information. In case the checks fail, the original error is returned.
func AddTagsToError ¶
AddTagsToError checks if the input error implements a causer interface. If it does, it checks if the Cause is of internal type *rung. When this check also passes, it adds the input _tags to the existing tags information. In case the checks fail, the original error is returned.
func Code ¶
This allows us to attach a response code with an error. This is achieved by implementing the errorCode interface:
type errorCode interface { Code() bool }
If the error does not implement errorCode, 500 will be returned. If the error is nil, 200 will be returned without further investigation. The logic will loop through the topmost error of the stack followed by all it's causes provided it implements the causer interface:
type causer interface { Cause() error }
If any one of the causes implements errorCode and returns a non-zero Code(), that code is returned to the calling function.
func Fatal ¶
Fatal is a condition to see if an error can be ignored or not. An error value has an Fatal condition if it implements the following interface:
type fatality interface { Fatal() bool }
If the error does not implement Fatal, false will be returned. If the error is nil, false will be returned without further investigation. The logic will loop through the topmost error of the stack followed by all it's causes provided it implements the causer interface:
type causer interface { Cause() error }
If any one of the causes is fatal, the error is deemed fatal. i.e. irrecoverable
func NewErrorToIgnore ¶
NewErrorToIgnore returns an error that informs loggers to ignore it
func NewErrorWithCode ¶
NewErrorWithCode returns an error that has an int code associated with it
func NewErrorWithExtras ¶
func NewErrorWithExtras(_msg string, _cause error, _fatal bool, _extras map[string]interface{}) error
Creates an error which is chained with a cause
func NewErrorWithTags ¶
Creates an error which is chained with a cause
func PrintStackTrace ¶
func PrintStackTrace(err error)
Printing the stacktrace of an error. It will print the entire stacktrace starting from the original root cause
func Stacktrace ¶
Determines the stacktrace of an error. It will retrieve the entire stacktrace starting from the original root cause
Types ¶
This section is empty.