25 lines
611 B
Go
25 lines
611 B
Go
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, ": ")
|
|
}
|