From 1ed809f56cd8a176a6cfca27be82e32950e0afae Mon Sep 17 00:00:00 2001 From: Michilis Date: Fri, 13 Nov 2026 22:31:45 +0000 Subject: [PATCH] Log the transport cause when a mint check fails Co-Authored-By: Claude Fable 5.1 --- internal/lnurlcash/errors.go | 24 ++++++++++++++++++++++++ internal/lnurlcash/mints.go | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 internal/lnurlcash/errors.go diff --git a/internal/lnurlcash/errors.go b/internal/lnurlcash/errors.go new file mode 100644 index 00000000..45ac7539 --- /dev/null +++ b/internal/lnurlcash/errors.go @@ -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, ": ") +} diff --git a/internal/lnurlcash/mints.go b/internal/lnurlcash/mints.go index f32a0473..e1533722 100644 --- a/internal/lnurlcash/mints.go +++ b/internal/lnurlcash/mints.go @@ -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 }