mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
27 lines
836 B
Go
27 lines
836 B
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// FormatErrorList() is a wrapper function that unifies error list formatting
|
|
// and makes printing error lists consistent.
|
|
//
|
|
// NOTE: The error returned IS NOT an error in itself and may be a bit misleading.
|
|
// Instead, it is a single condensed error composed of all of the errors included
|
|
// in the errList argument.
|
|
func FormatErrorList(errList []error) error {
|
|
var err error
|
|
for i, e := range errList {
|
|
// NOTE: for multi-error formating, we want to include \n here
|
|
err = fmt.Errorf("\t[%d] %v\n", i, e)
|
|
}
|
|
return err
|
|
}
|
|
|
|
// HasErrors() is a simple wrapper function to check if an error list contains
|
|
// errors. Having a function that clearly states its purpose helps to improve
|
|
// readibility although it may seem pointless.
|
|
func HasErrors(errList []error) bool {
|
|
return len(errList) > 0
|
|
}
|