Log the transport cause when a mint check fails

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-13 22:31:45 +00:00
co-authored by Claude Fable 5.1
parent 3c2ccf8d83
commit 1ed809f56c
2 changed files with 25 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
package lnurlcash
import (
"errors"
"strings"
)
// Describe renders an error with the transport cause an AmbiguousError hides
// behind its detail, so a log line says why a mint could not be reached.
func Describe(err error) string {
if err == nil {
return ""
}
parts := []string{err.Error()}
for e := err; e != nil; e = errors.Unwrap(e) {
var ambiguous interface{ Unwrap() error }
if errors.As(e, &ambiguous) {
if cause := ambiguous.Unwrap(); cause != nil && !strings.Contains(parts[0], cause.Error()) {
parts = append(parts, cause.Error())
}
}
}
return strings.Join(parts, ": ")
}
+1 -1
View File
@@ -79,7 +79,7 @@ func (r *Registry) Check(ctx context.Context, id string) error {
log.Errorf("[lnurlcash] save mint %s: %v", id, serr)
}
if err != nil {
log.Warnf("[lnurlcash] mint %s unhealthy: %v", id, err)
log.Warnf("[lnurlcash] mint %s unhealthy: %s", id, Describe(err))
}
return err
}