mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-19 17:50:00 +00:00
24 lines
580 B
Go
24 lines
580 B
Go
package multierror
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// ErrorFormatFunc is a function callback that is called by Error to
|
|
// turn the list of errors into a string.
|
|
type ErrorFormatFunc func([]error) string
|
|
|
|
// ListFormatFunc is a basic formatter that outputs the number of errors
|
|
// that occurred along with a bullet point list of the errors.
|
|
func ListFormatFunc(es []error) string {
|
|
points := make([]string, len(es))
|
|
for i, err := range es {
|
|
points[i] = fmt.Sprintf("* %s", err)
|
|
}
|
|
|
|
return fmt.Sprintf(
|
|
"%d error(s) occurred:\n\n%s",
|
|
len(es), strings.Join(points, "\n"))
|
|
}
|