From 2f1b784dc2b052194e3e91ac82de1e7a408ba76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Fri, 28 Jul 2023 15:42:12 +0200 Subject: [PATCH] v0.0.219 implement error.Is(*) for exerr --- exerr/exerr.go | 8 +++++++- exerr/helper.go | 2 ++ goextVersion.go | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/exerr/exerr.go b/exerr/exerr.go index 5064f18..f423e06 100644 --- a/exerr/exerr.go +++ b/exerr/exerr.go @@ -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)) } diff --git a/exerr/helper.go b/exerr/helper.go index 8392ceb..7ac0f21 100644 --- a/exerr/helper.go +++ b/exerr/helper.go @@ -24,6 +24,8 @@ func IsFrom(e error, original error) bool { if e == nil { return false } + + //goland:noinspection GoDirectComparisonOfErrors if e == original { return true } diff --git a/goextVersion.go b/goextVersion.go index ff6f213..c1a9e57 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.218" +const GoextVersion = "0.0.219" -const GoextVersionTimestamp = "2023-07-27T17:16:30+0200" +const GoextVersionTimestamp = "2023-07-28T15:42:12+0200"