Add comments to exported error helpers. (#20)

Noticed via the go report!
This commit is contained in:
Matt Moore 2018-07-26 16:40:35 -07:00 committed by Google Prow Robot
parent 63b563207a
commit 84f0a719d7
1 changed files with 3 additions and 0 deletions

View File

@ -85,6 +85,7 @@ func (fe *FieldError) Error() string {
return fmt.Sprintf("%v: %v\n%v", fe.Message, strings.Join(fe.Paths, ", "), fe.Details)
}
// ErrMissingField is a variadic helper method for constructing a FieldError for a set of missing fields.
func ErrMissingField(fieldPaths ...string) *FieldError {
return &FieldError{
Message: "missing field(s)",
@ -92,6 +93,7 @@ func ErrMissingField(fieldPaths ...string) *FieldError {
}
}
// ErrDisallowedFields is a variadic helper method for constructing a FieldError for a set of disallowed fields.
func ErrDisallowedFields(fieldPaths ...string) *FieldError {
return &FieldError{
Message: "must not set the field(s)",
@ -99,6 +101,7 @@ func ErrDisallowedFields(fieldPaths ...string) *FieldError {
}
}
// ErrInvalidValue constructs a FieldError for a field that has received an invalid string value.
func ErrInvalidValue(value string, fieldPath string) *FieldError {
return &FieldError{
Message: fmt.Sprintf("invalid value %q", value),