Documentation ¶
Index ¶
- func BuildErr(SID ErrSID) func(string, int, ErrKind) *Err
- func Equals(err error, other *Err) bool
- func In(err error, list ...*Err) bool
- func ProducedByService(err error, sid ErrSID) bool
- type Err
- func (err *Err) AddDetailF(formatS string, args ...interface{}) *Err
- func (err *Err) AddDetails(details ...string) *Err
- func (err *Err) AddDetailsErr(details ...error) *Err
- func (err *Err) Emit() *Err
- func (err *Err) EmitDefault(defaulterr Err) *Err
- func (err *Err) Equals(other *Err) bool
- func (err *Err) Error() string
- func (err *Err) Log(origin error, logger ErrorLogger) *Err
- func (err *Err) WithField(name, value string) *Err
- func (err *Err) WithFields(fields Fields) *Err
- type ErrConstruct
- func (constr ErrConstruct) AddDetailF(f string, vals ...interface{}) ErrConstruct
- func (constr ErrConstruct) AddDetails(details ...string) ErrConstruct
- func (constr ErrConstruct) AddDetailsErr(details ...error) ErrConstruct
- func (constr ErrConstruct) Error() string
- func (constr ErrConstruct) WithField(key, value string) ErrConstruct
- func (constr ErrConstruct) WithFields(fields Fields) ErrConstruct
- type ErrID
- type ErrKind
- type ErrSID
- type ErrorLogger
- type Fields
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildErr ¶
BuildErr -- produces Err constructor with custom ID prefix Example:
MyErr := BuildErr("serivice_id") ErrNotEnoughCheese = MyErr("not enough cheese", "666") --> "not enough cheese [service_id666]"
func Equals ¶
Equals -- attempts to compare error with cherry error. If error is not *Err returns false. Otherwise uses (*Err).Equals() for comparison.
func ProducedByService ¶
ProducedByService -- determines whether error produced by given service If err is not *Err returns false. Otherwise compares (*Err).ID.SID with sid.
Types ¶
type Err ¶
type Err struct { Message string `json:"message"` StatusHTTP int `json:"status_http"` ID ErrID `json:"id"` Details []string `json:"details,omitempty"` Fields Fields `json:"fields,omitempty"` }
Err -- standard serializable API error Message -- constant error message:
- "invalid username"
- "quota exceeded"
- "validation error" ...etc...
ID -- unique error identification code Details -- optional context error messages kinda
- "field 'Replicas' must be non-zero value"
- "not enough tights to feed gopher"
- "resource 'God' does't exist"
Fields -- optional set of key-value pairs swagger:model
func WhichOne ¶
WhichOne -- searches err in list of cherry errs. If err is in list returns list item which equals to err. If err is not in list returns nil. Uses (*Err).Equals() for comparison.
func (*Err) AddDetailF ¶
AddDetailF --adds formatted message to Err, chainable
func (*Err) AddDetails ¶
AddDetails -- adds detail messages to Err, chainable
func (*Err) AddDetailsErr ¶
AddDetailsErr -- adds errors as detail messages to Err, chainable
func (*Err) EmitDefault ¶
func (*Err) Equals ¶
Equals -- compares with other cherry error. Two cherry errors equal if IDs are deep equal (Kind and SID are equal).
func (*Err) Log ¶
func (err *Err) Log(origin error, logger ErrorLogger) *Err
Log -- logs origin error for returning error using ErrLogger, Chainable.
func (*Err) WithFields ¶
WithFields -- adds fields to Err, chainable
type ErrConstruct ¶
func (ErrConstruct) AddDetailF ¶
func (constr ErrConstruct) AddDetailF(f string, vals ...interface{}) ErrConstruct
func (ErrConstruct) AddDetails ¶
func (constr ErrConstruct) AddDetails(details ...string) ErrConstruct
func (ErrConstruct) AddDetailsErr ¶
func (constr ErrConstruct) AddDetailsErr(details ...error) ErrConstruct
func (ErrConstruct) Error ¶
func (constr ErrConstruct) Error() string
func (ErrConstruct) WithField ¶
func (constr ErrConstruct) WithField(key, value string) ErrConstruct
func (ErrConstruct) WithFields ¶
func (constr ErrConstruct) WithFields(fields Fields) ErrConstruct
type ErrorLogger ¶
ErrLogger -- interface for logging origin and returned errors due to origin errors discarding
Directories ¶
Path | Synopsis |
---|---|
adaptors
|
|
cmd
|
|
exampleErrors
Code generated by noice.
|
Code generated by noice. |
pkg
|
|