feat: add util function to format error list
This commit is contained in:
parent
2eee847205
commit
215dbe8eff
1 changed files with 10 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"cmp"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
|
@ -97,3 +98,12 @@ func CopyIf[T comparable](s []T, condition func(t T) bool) []T {
|
|||
}
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue