mirror of https://git.sr.ht/~sircmpwn/core-go
valid: Add Error function
Add an Error function which is similar to Errorf except that it does not take a format specifier.
This commit is contained in:
parent
33bc768cc7
commit
3e8e0173f8
|
@ -18,6 +18,17 @@ type ValidationError struct {
|
|||
err *gqlerror.Error
|
||||
}
|
||||
|
||||
// Returns a new GraphQL error attached to the given field.
|
||||
func Error(ctx context.Context, field string, msg string) error {
|
||||
return &gqlerror.Error{
|
||||
Message: msg,
|
||||
Path: graphql.GetPath(ctx),
|
||||
Extensions: map[string]interface{}{
|
||||
"field": field,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a new GraphQL error attached to the given field.
|
||||
func Errorf(ctx context.Context, field string, msg string, items ...interface{}) error {
|
||||
return &gqlerror.Error{
|
||||
|
|
Loading…
Reference in New Issue