Documentation ¶
Index ¶
- Variables
- func Append(left, right error) error
- func Combine(errList ...error) error
- func HasError(err error, errText string) bool
- func LastAppended(err error) error
- func WithStatus(err string, status int) error
- type Error
- type ErrorWithStatusProvider
- type HashableMapper
- type IgnoreListMapper
- type ListMapper
- type Mapper
- type MultiErr
- type PairErrors
Constants ¶
This section is empty.
Variables ¶
var ( WithStatusBadRequest = WithStatus(http.StatusText(http.StatusBadRequest), http.StatusBadRequest) WithStatusInternalServerError = WithStatus(http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) )
Default error with statuses
Functions ¶
func LastAppended ¶
LastAppended return the lastErr error appended as multierr
func WithStatus ¶
WithStatus return an error with an associated status
Types ¶
type Error ¶
Error which exposes a method that determines if the error can be considered equal or not
type ErrorWithStatusProvider ¶
ErrorWithStatusProvider defines an error which also has an http status defined
type HashableMapper ¶
HashableMapper simple implementation of Mapper which only works on hashable error keys
func NewHashableMapper ¶
func NewHashableMapper() HashableMapper
NewHashableMapper make a new instance of HashableMapper
func (HashableMapper) Append ¶
func (hm HashableMapper) Append(err, match error) HashableMapper
Append append an error to error association
type IgnoreListMapper ¶
type IgnoreListMapper struct {
// contains filtered or unexported fields
}
IgnoreListMapper is a Mapper that allow to specify a list of error that we want to ignore
func NewIgnoreListMapper ¶
func NewIgnoreListMapper() IgnoreListMapper
NewIgnoreListMapper create an instance of IgnoreListMapper
func (IgnoreListMapper) Append ¶
func (lm IgnoreListMapper) Append(err error) IgnoreListMapper
Append appends an error that we want to ignore
func (IgnoreListMapper) Appendf ¶
func (lm IgnoreListMapper) Appendf(format string) IgnoreListMapper
Appendf appends a formatted error that we want to ignore
type ListMapper ¶
type ListMapper struct {
// contains filtered or unexported fields
}
ListMapper maps not hashable or formatted errorPairs
func (ListMapper) Append ¶
func (lm ListMapper) Append(err, match error) ListMapper
Append append an error to error association
func (ListMapper) Appendf ¶
func (lm ListMapper) Appendf(format string, match error) ListMapper
Appendf append a format to error association
type Mapper ¶
type Mapper interface {
// contains filtered or unexported methods
}
Mapper takes an error and return a mapResult
type MultiErr ¶
type MultiErr struct {
// contains filtered or unexported fields
}
MultiErr an error to another error
func NewMultiErr ¶
NewMultiErr return a new instance of MultiErr
func (MultiErr) LastMappedWithStatus ¶
func (m MultiErr) LastMappedWithStatus(err error) ErrorWithStatusProvider
LastMappedWithStatus return the lastErr mapped error with the associated http status Deprecated: consider using MappedWithStatus() instead, as encourages to specify a default error
func (MultiErr) MappedWithStatus ¶
func (m MultiErr) MappedWithStatus(err, defaultErr error) ErrorWithStatusProvider
MappedWithStatus return the lastErr mapped error with the associated http status You can optionally provide a default error in case that will be returned if the error has not been mapped
defaultErr == nil returns the ErrorWithStatusProvider only if error is mapped
alias for LastMappedWithStatus(err)
defaultErr.(ErrorWithStatusProvider) allow you to specify a status code
e.g.: maperr.WithStatus("USER_ERROR", http.StatusBadRequest)
defaultErr.(error) will cast to a ErrorWithStatusProvider with http.StatusInternalServerError
type PairErrors ¶
type PairErrors struct {
// contains filtered or unexported fields
}
PairErrors holds a pair of errorPairs