48 lines
967 B
Go
48 lines
967 B
Go
package goap
|
|
|
|
import "fmt"
|
|
|
|
type NoRequiredFieldError struct {
|
|
FieldName string
|
|
}
|
|
|
|
func (n NoRequiredFieldError) Error() string {
|
|
return fmt.Sprintf("no attribute named %s", n.FieldName)
|
|
}
|
|
|
|
type BadFieldValueError struct {
|
|
FieldName string
|
|
RawValue any
|
|
Expected any
|
|
}
|
|
|
|
func (b BadFieldValueError) Error() string {
|
|
return fmt.Sprintf(
|
|
"attribute %s has a bad raw value, inspect error struct for raw and expected value",
|
|
b.FieldName,
|
|
)
|
|
}
|
|
|
|
type BadFieldArrayLengthError struct {
|
|
FieldName string
|
|
ExpectedLen int
|
|
ActualLen int
|
|
}
|
|
|
|
func (b BadFieldArrayLengthError) Error() string {
|
|
return fmt.Sprintf(
|
|
"attribute %s expects an array of length %d but got an array with %d elements",
|
|
b.FieldName,
|
|
b.ExpectedLen,
|
|
b.ActualLen,
|
|
)
|
|
}
|
|
|
|
type NoRequiredSubFieldError struct {
|
|
FieldName string
|
|
Subfield string
|
|
}
|
|
|
|
func (n NoRequiredSubFieldError) Error() string {
|
|
return fmt.Sprintf("missing subfield %s for attribute %s", n.Subfield, n.FieldName)
|
|
}
|