mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-03 16:57:38 -05:00
31 lines
457 B
Go
31 lines
457 B
Go
|
package errors
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
type multiError []error
|
||
|
|
||
|
func (e multiError) Error() string {
|
||
|
var r strings.Builder
|
||
|
r.WriteString("multierr: ")
|
||
|
for _, err := range e {
|
||
|
r.WriteString(err.Error())
|
||
|
r.WriteString(" | ")
|
||
|
}
|
||
|
return r.String()
|
||
|
}
|
||
|
|
||
|
func Combine(maybeError ...error) error {
|
||
|
var errs multiError
|
||
|
for _, err := range maybeError {
|
||
|
if err != nil {
|
||
|
errs = append(errs, err)
|
||
|
}
|
||
|
}
|
||
|
if len(errs) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
return errs
|
||
|
}
|