v0.0.356 exerr.GetMeta
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m9s

This commit is contained in:
Mike Schwörer 2024-01-05 10:43:39 +01:00
parent 2a0471fb3d
commit 9264a2e99b
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 14 additions and 2 deletions

View File

@ -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 {

View File

@ -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"