1Panel/backend/buserr/multi_err.go
2022-12-20 23:22:34 +08:00

24 lines
365 B
Go

package buserr
import (
"bytes"
"fmt"
"sort"
)
type MultiErr map[string]error
func (e MultiErr) Error() string {
var keys []string
for key := range e {
keys = append(keys, key)
}
sort.Strings(keys)
buffer := bytes.NewBufferString("")
for _, key := range keys {
buffer.WriteString(fmt.Sprintf("[%s] %s\n", key, e[key]))
}
return buffer.String()
}