Documentation ¶
Index ¶
- Constants
- func ConcatErrors(errs ...error) error
- func ConcatErrorsMessage(errs ...error) string
- func DontPanic(f func()) (err error)
- func E(args ...interface{}) error
- func EqualsCode(lCode, rCode Code) bool
- func Errorf(s string, params ...interface{}) error
- func GetRootError(err error) error
- func GetRootErrorWithKV(err error) error
- func New(s string) error
- func SameCode(lError, rError error) bool
- type Code
- type Error
- type KeyValue
- type Op
- type Severity
Constants ¶
const ( // ErrorCodeEmpty is an empty error code // Deprecated: prefer CodeEmpty ErrorCodeEmpty = CodeEmpty // CodeEmpty is the zero-value for error codes CodeEmpty = Code("") )
const ( // SeverityUnset indicates the severity was not set SeverityUnset = Severity("") // SeverityRuntime indicates the error is returned for an operation that should/could be executed again. For example, timeouts. SeverityRuntime = Severity("runtime") // SeverityFatal indicates the error is unrecoverable and the execution should stop, or not being retried. SeverityFatal = Severity("fatal") // SeverityInput indicates an expected, like a bad user input/request. For example, an invalid email. SeverityInput = Severity("input") )
Variables ¶
This section is empty.
Functions ¶
func ConcatErrorsMessage ¶
ConcatErrorsMessage concatenates all the error messages from the given errors
func DontPanic ¶
func DontPanic(f func()) (err error)
DontPanic executes f and, if f panics, recovers from the panic and returns the panic wrapped as an Error.
func EqualsCode ¶
EqualsCode returns true if @lCode and @rCode holds the same value, and false otherwise
func GetRootError ¶
GetRootError returns the Err field of Error struct or the error itself if it is of another type
func GetRootErrorWithKV ¶
GetRootErrorWithKV returns the Err field of Error struct or the error itself if it is of another type
Types ¶
type Code ¶
type Code string
Code is the error code
var CodePanic Code = "PANIC"
CodePanic represents the error code for panic
func GetCode ¶
GetCode returns the error code. If the error doesn't contains an error code, returns ErrorCodeEmpty
func GetErrorCode
deprecated
func (Code) MarshalZerologObject ¶
MarshalZerologObject allows for zerolog to log the error code as 'error_code': '...'
type Error ¶
Error represents the error struct that should be returned in all functions Error implements the Go's error interface
func NewFromRecover ¶
func NewFromRecover(r interface{}) Error
NewFromRecover returns a new Error created from the result of a recover. If r is an Error, this will be used so Op and KV are preserved
type KeyValue ¶
type KeyValue struct { Key interface{} Value interface{} }
KeyValue is used to store a key-value pair within the error
type Severity ¶
type Severity string
Severity is the error severity. It's used to classify errors in groups to be easily handled by the code. For example, a retry layer should be only checking for Runtime errors to retry. Or in an HTTP layer, errors of input type are always returned a 400 status.
func GetSeverity ¶
GetSeverity returns the error severity. If there is not severity, SeverityUnset is returned.
func (Severity) MarshalZerologObject ¶
MarshalZerologObject allows for zerolog to log the error severity as 'error_severity': '...'