feat: initial commit
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
This commit is contained in:
33
internal/schema/error.go
Normal file
33
internal/schema/error.go
Normal file
@ -0,0 +1,33 @@
|
||||
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}
|
||||
}
|
Reference in New Issue
Block a user