diff --git a/exerr/exerr.go b/exerr/exerr.go index 02887c5..01855d2 100644 --- a/exerr/exerr.go +++ b/exerr/exerr.go @@ -258,6 +258,18 @@ func (ee *ExErr) Depth() int { } } +// GetMeta returns the meta value with the specified key +// this method recurses through all wrapped errors and returns the first matching meta value +func (ee *ExErr) GetMeta(key string) (any, bool) { + for curr := ee; curr != nil; curr = curr.OriginalError { + if v, ok := curr.Meta[key]; ok { + return v.Value, true + } + } + + return nil, false +} + // contains test if the supplied error is contained in this error (anywhere in the chain) func (ee *ExErr) contains(original *ExErr) (*ExErr, bool) { if original == nil { diff --git a/goextVersion.go b/goextVersion.go index 2d1eaec..c0a20c4 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.355" +const GoextVersion = "0.0.356" -const GoextVersionTimestamp = "2024-01-05T10:25:05+0100" +const GoextVersionTimestamp = "2024-01-05T10:43:39+0100"