Documentation ¶
Index ¶
- Constants
- func ConcatErrors(errs ...error) error
- func ConcatErrorsMessage(errs ...error) string
- func E(args ...interface{}) error
- func Errorf(s string, params ...interface{}) error
- func GetRootError(err error) error
- func GetRootErrorWithKV(err error) error
- func New(s string) error
- type Code
- type Error
- type HTTPStatus
- type KeyValue
- type Op
- type Severity
Constants ¶
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") )
const ( // ErrorCodeEmpty is an empty error code ErrorCodeEmpty = Code("") )
Variables ¶
This section is empty.
Functions ¶
func ConcatErrorsMessage ¶
ConcatErrorsMessage concatenates all the error messages from the given errors
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
func GetErrorCode ¶
GetErrorCode returns the error code. If the error doen't contains an error code, returns ErrorCodeEmpty.
type Error ¶
type Error struct { Severity Severity Err error Code Code Op Op HTTPStatus HTTPStatus KVs []KeyValue }
Error represents the error struct that should be returned in all functions Error implements the Go's error interface
type HTTPStatus ¶
type HTTPStatus int
HTTPStatus sets an http status for the error
func GetHTTPStatus ¶
func GetHTTPStatus(err error) HTTPStatus
GetHTTPStatus returns the HTTPStatus of an error.
func (HTTPStatus) String ¶
func (s HTTPStatus) String() string
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 examle, a retry layer should be only checking for Runtime erros to retry. Or in an HTTP layer, erros of input type are always returned a 400 status.
func GetSeverity ¶
GetSeverity returns the error severity. If there is not severity, SeverityUnset is returned.