v0.0.219 implement error.Is(*) for exerr
This commit is contained in:
@@ -22,7 +22,7 @@ type ExErr struct {
|
||||
WrappedErrType string `json:"wrappedErrType"`
|
||||
Caller string `json:"caller"`
|
||||
|
||||
OriginalError *ExErr
|
||||
OriginalError *ExErr `json:"originalError"`
|
||||
|
||||
Meta MetaMap `json:"meta"`
|
||||
}
|
||||
@@ -31,10 +31,16 @@ func (ee *ExErr) Error() string {
|
||||
return ee.Message
|
||||
}
|
||||
|
||||
// Unwrap must be implemented so that some error.XXX methods work
|
||||
func (ee *ExErr) Unwrap() error {
|
||||
return ee.OriginalError
|
||||
}
|
||||
|
||||
// Is must be implemented so that error.Is(x) works
|
||||
func (ee *ExErr) Is(e error) bool {
|
||||
return IsFrom(ee, e)
|
||||
}
|
||||
|
||||
func (ee *ExErr) Log(evt *zerolog.Event) {
|
||||
evt.Msg(ee.FormatLog(LogPrintFull))
|
||||
}
|
||||
|
Reference in New Issue
Block a user