1
0
Fork 0
mirror of https://github.com/Luzifer/duplicity-backup.git synced 2024-11-14 01:42:52 +00:00
duplicity-backup/vendor/github.com/asaskevich/govalidator/error.go

37 lines
783 B
Go
Raw Normal View History

2016-05-22 13:04:37 +00:00
package govalidator
import "strings"
2016-05-22 13:04:37 +00:00
// Errors is an array of multiple errors and conforms to the error interface.
type Errors []error
// Errors returns itself.
func (es Errors) Errors() []error {
return es
}
func (es Errors) Error() string {
var errs []string
2016-05-22 13:04:37 +00:00
for _, e := range es {
errs = append(errs, e.Error())
2016-05-22 13:04:37 +00:00
}
return strings.Join(errs, ";")
2016-05-22 13:04:37 +00:00
}
// Error encapsulates a name, an error and whether there's a custom error message or not.
type Error struct {
Name string
Err error
CustomErrorMessageExists bool
// Validator indicates the name of the validator that failed
Validator string
2016-05-22 13:04:37 +00:00
}
func (e Error) Error() string {
if e.CustomErrorMessageExists {
return e.Err.Error()
}
return e.Name + ": " + e.Err.Error()
}