-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
73 lines (62 loc) · 1.64 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package gql
/*
Errors is an alias for a bunch of Error
*/
type Errors []*Error
/*
Error for the Result of the validation/execution
*/
type Error struct {
Message string `json:"message"`
Locations []*ErrorLocation `json:"locations"`
Path []interface{} `json:"path"`
Extensions map[string]interface{} `json:"extensions,omitempty"`
}
/*
Error implements the error interface
*/
func (e *Error) Error() string {
return e.Message
}
/*
ErrorLocation represents the location of an error in the query
*/
type ErrorLocation struct {
Line int `json:"line"`
Column int `json:"column"`
}
/*
NewError ...
*/
func NewError(msg string, extensions map[string]interface{}) CustomError {
return &cErr{
msg: msg,
exts: extensions,
}
}
type cErr struct {
msg string
exts map[string]interface{}
}
func (c *cErr) Error() string {
return c.msg
}
func (c *cErr) GetMessage() string {
return c.msg
}
func (c *cErr) GetExtensions() map[string]interface{} {
return c.exts
}
type CustomError interface {
error
GetMessage() string
GetExtensions() map[string]interface{}
}
const (
errValidateOperationName = "Operation name '%s' is defined multiple times"
errAnonymousOperationDefinitions = "Can not use anonymous operation where multiple operation definitions exist"
errLeafFieldSelectionsSelectionNotAllowed = "Selection on type '%s' is not allowed"
errLeafFieldSelectionsSelectionMissing = "Selection on type '%s' is missing"
errFieldDoesNotExist = "Field '%s' does not exist on type '%s'"
errResponseShapeMismatch = "fields in set can not be merged: %s"
)