bouncer/internal/schema/error.go
William Petit e66938f1d3
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
feat: initial commit
2023-05-21 22:27:25 +02:00

34 lines
653 B
Go

package schema
import (
"errors"
"fmt"
"github.com/qri-io/jsonschema"
)
var (
ErrSchemaNotFound = errors.New("schema not found")
ErrInvalidData = errors.New("invalid data")
)
type InvalidDataError struct {
keyErrors []jsonschema.KeyError
}
func (e *InvalidDataError) Is(err error) bool {
return err == ErrInvalidData
}
func (e *InvalidDataError) Error() string {
return fmt.Sprintf("%s: %s", ErrInvalidData.Error(), e.keyErrors)
}
func (e *InvalidDataError) KeyErrors() []jsonschema.KeyError {
return e.keyErrors
}
func NewInvalidDataError(keyErrors ...jsonschema.KeyError) *InvalidDataError {
return &InvalidDataError{keyErrors}
}