diff --git a/exerr/exerr.go b/exerr/exerr.go index e65055f..5064f18 100644 --- a/exerr/exerr.go +++ b/exerr/exerr.go @@ -162,7 +162,6 @@ func (ee *ExErr) RecursiveStatuscode() *int { } } - // fallback to return nil } @@ -179,6 +178,18 @@ func (ee *ExErr) RecursiveCategory() ErrorCategory { return ee.Category } +// RecursiveMeta searches (top-down) for teh first error that has a meta value with teh specified key +// and returns its value (or nil) +func (ee *ExErr) RecursiveMeta(key string) *MetaValue { + for curr := ee; curr != nil; curr = curr.OriginalError { + if metaval, ok := curr.Meta[key]; ok { + return langext.Ptr(metaval) + } + } + + return nil +} + func (ee *ExErr) Depth() int { if ee.OriginalError == nil { return 1 diff --git a/goextVersion.go b/goextVersion.go index 1681a20..09c8430 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.193" +const GoextVersion = "0.0.194" -const GoextVersionTimestamp = "2023-07-24T11:38:57+0200" +const GoextVersionTimestamp = "2023-07-24T11:40:47+0200"