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

32 lines
653 B
Go
Raw Normal View History

2016-01-25 05:30:04 +00:00
package govalidator
// Errors is an array of multiple errors and conforms to the error interface.
2016-01-25 05:30:04 +00:00
type Errors []error
// Errors returns itself.
2016-01-25 05:30:04 +00: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-25 05:30:04 +00:00
type Error struct {
2016-04-24 08:13:39 +00:00
Name string
Err error
CustomErrorMessageExists bool
2016-01-25 05:30:04 +00:00
}
func (e Error) Error() string {
2016-04-24 08:13:39 +00:00
if e.CustomErrorMessageExists {
return e.Err.Error()
}
return e.Name + ": " + e.Err.Error()
2016-01-25 05:30:04 +00:00
}