feat: add util function to format error list

This commit is contained in:
David Allen 2025-09-04 10:07:10 -06:00
parent 2eee847205
commit 215dbe8eff
Signed by: towk
GPG key ID: 793B2924A49B3A3F

View file

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"cmp" "cmp"
"crypto/tls" "crypto/tls"
"errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -97,3 +98,12 @@ func CopyIf[T comparable](s []T, condition func(t T) bool) []T {
} }
return f return f
} }
func FormatErrors(message string, prefix string, errs []error) error {
var errMessage = prefix + message + "\n"
for _, err := range errs {
errMessage = fmt.Sprintf("%s %v\n", prefix, err)
}
return errors.New(errMessage)
}