prometheus/vendor/github.com/asaskevich/govalidator/error.go

32 lines
653 B
Go
Raw Normal View History

2016-01-24 21:30:04 -08:00
package govalidator
// Errors is an array of multiple errors and conforms to the error interface.
2016-01-24 21:30:04 -08:00
type Errors []error
// Errors returns itself.
2016-01-24 21:30:04 -08:00
func (es Errors) Errors() []error {
return es
}
func (es Errors) Error() string {
var err string
for _, e := range es {
err += e.Error() + ";"
}
return err
}
// Error encapsulates a name, an error and whether there's a custom error message or not.
2016-01-24 21:30:04 -08:00
type Error struct {
2016-04-24 01:13:39 -07:00
Name string
Err error
CustomErrorMessageExists bool
2016-01-24 21:30:04 -08:00
}
func (e Error) Error() string {
2016-04-24 01:13:39 -07:00
if e.CustomErrorMessageExists {
return e.Err.Error()
}
return e.Name + ": " + e.Err.Error()
2016-01-24 21:30:04 -08:00
}