v0.0.312 improve exerr.RecursiveMessage()
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m23s

This commit is contained in:
Mike Schwörer 2023-11-10 10:16:31 +01:00
parent 1971f1396f
commit ff8f128fe8
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 21 additions and 3 deletions

View File

@ -169,14 +169,32 @@ func (ee *ExErr) ShortLog(evt *zerolog.Event) {
// RecursiveMessage returns the message to show
// = first error (top-down) that is not wrapping/foreign/empty
// = lowest level error (that is not empty)
// = fallback to self.message
func (ee *ExErr) RecursiveMessage() string {
// ==== [1] ==== first error (top-down) that is not wrapping/foreign/empty
for curr := ee; curr != nil; curr = curr.OriginalError {
if curr.Message != "" && curr.Category != CatWrap && curr.Category != CatForeign {
return curr.Message
}
}
// fallback to self
// ==== [2] ==== lowest level error (that is not empty)
deepestMsg := ""
for curr := ee; curr != nil; curr = curr.OriginalError {
if curr.Message != "" {
deepestMsg = curr.Message
}
}
if deepestMsg != "" {
return deepestMsg
}
// ==== [3] ==== fallback to self.message
return ee.Message
}

View File

@ -1,5 +1,5 @@
package goext
const GoextVersion = "0.0.311"
const GoextVersion = "0.0.312"
const GoextVersionTimestamp = "2023-11-09T11:48:45+0100"
const GoextVersionTimestamp = "2023-11-10T10:16:31+0100"