diff options
Diffstat (limited to 'vendor/github.com/graphql-go/graphql/gqlerrors')
5 files changed, 0 insertions, 257 deletions
diff --git a/vendor/github.com/graphql-go/graphql/gqlerrors/error.go b/vendor/github.com/graphql-go/graphql/gqlerrors/error.go deleted file mode 100644 index 1b289bbb..00000000 --- a/vendor/github.com/graphql-go/graphql/gqlerrors/error.go +++ /dev/null @@ -1,68 +0,0 @@ -package gqlerrors - -import ( - "fmt" - "reflect" - - "github.com/graphql-go/graphql/language/ast" - "github.com/graphql-go/graphql/language/location" - "github.com/graphql-go/graphql/language/source" -) - -type Error struct { - Message string - Stack string - Nodes []ast.Node - Source *source.Source - Positions []int - Locations []location.SourceLocation - OriginalError error -} - -// implements Golang's built-in `error` interface -func (g Error) Error() string { - return fmt.Sprintf("%v", g.Message) -} - -func NewError(message string, nodes []ast.Node, stack string, source *source.Source, positions []int, origError error) *Error { - if stack == "" && message != "" { - stack = message - } - if source == nil { - for _, node := range nodes { - // get source from first node - if node == nil || reflect.ValueOf(node).IsNil() { - continue - } - if node.GetLoc() != nil { - source = node.GetLoc().Source - } - break - } - } - if len(positions) == 0 && len(nodes) > 0 { - for _, node := range nodes { - if node == nil || reflect.ValueOf(node).IsNil() { - continue - } - if node.GetLoc() == nil { - continue - } - positions = append(positions, node.GetLoc().Start) - } - } - locations := []location.SourceLocation{} - for _, pos := range positions { - loc := location.GetLocation(source, pos) - locations = append(locations, loc) - } - return &Error{ - Message: message, - Stack: stack, - Nodes: nodes, - Source: source, - Positions: positions, - Locations: locations, - OriginalError: origError, - } -} diff --git a/vendor/github.com/graphql-go/graphql/gqlerrors/formatted.go b/vendor/github.com/graphql-go/graphql/gqlerrors/formatted.go deleted file mode 100644 index 3a1f8853..00000000 --- a/vendor/github.com/graphql-go/graphql/gqlerrors/formatted.go +++ /dev/null @@ -1,51 +0,0 @@ -package gqlerrors - -import ( - "errors" - - "github.com/graphql-go/graphql/language/location" -) - -type FormattedError struct { - Message string `json:"message"` - Locations []location.SourceLocation `json:"locations"` -} - -func (g FormattedError) Error() string { - return g.Message -} - -func NewFormattedError(message string) FormattedError { - err := errors.New(message) - return FormatError(err) -} - -func FormatError(err error) FormattedError { - switch err := err.(type) { - case FormattedError: - return err - case *Error: - return FormattedError{ - Message: err.Error(), - Locations: err.Locations, - } - case Error: - return FormattedError{ - Message: err.Error(), - Locations: err.Locations, - } - default: - return FormattedError{ - Message: err.Error(), - Locations: []location.SourceLocation{}, - } - } -} - -func FormatErrors(errs ...error) []FormattedError { - formattedErrors := []FormattedError{} - for _, err := range errs { - formattedErrors = append(formattedErrors, FormatError(err)) - } - return formattedErrors -} diff --git a/vendor/github.com/graphql-go/graphql/gqlerrors/located.go b/vendor/github.com/graphql-go/graphql/gqlerrors/located.go deleted file mode 100644 index b02fcd8a..00000000 --- a/vendor/github.com/graphql-go/graphql/gqlerrors/located.go +++ /dev/null @@ -1,39 +0,0 @@ -package gqlerrors - -import ( - "errors" - "github.com/graphql-go/graphql/language/ast" -) - -// NewLocatedError creates a graphql.Error with location info -// @deprecated 0.4.18 -// Already exists in `graphql.NewLocatedError()` -func NewLocatedError(err interface{}, nodes []ast.Node) *Error { - var origError error - message := "An unknown error occurred." - if err, ok := err.(error); ok { - message = err.Error() - origError = err - } - if err, ok := err.(string); ok { - message = err - origError = errors.New(err) - } - stack := message - return NewError( - message, - nodes, - stack, - nil, - []int{}, - origError, - ) -} - -func FieldASTsToNodeASTs(fieldASTs []*ast.Field) []ast.Node { - nodes := []ast.Node{} - for _, fieldAST := range fieldASTs { - nodes = append(nodes, fieldAST) - } - return nodes -} diff --git a/vendor/github.com/graphql-go/graphql/gqlerrors/sortutil.go b/vendor/github.com/graphql-go/graphql/gqlerrors/sortutil.go deleted file mode 100644 index 300a9407..00000000 --- a/vendor/github.com/graphql-go/graphql/gqlerrors/sortutil.go +++ /dev/null @@ -1,30 +0,0 @@ -package gqlerrors - -import "bytes" - -type FormattedErrors []FormattedError - -func (errs FormattedErrors) Len() int { - return len(errs) -} - -func (errs FormattedErrors) Swap(i, j int) { - errs[i], errs[j] = errs[j], errs[i] -} - -func (errs FormattedErrors) Less(i, j int) bool { - mCompare := bytes.Compare([]byte(errs[i].Message), []byte(errs[j].Message)) - lesserLine := errs[i].Locations[0].Line < errs[j].Locations[0].Line - eqLine := errs[i].Locations[0].Line == errs[j].Locations[0].Line - lesserColumn := errs[i].Locations[0].Column < errs[j].Locations[0].Column - if mCompare < 0 { - return true - } - if mCompare == 0 && lesserLine { - return true - } - if mCompare == 0 && eqLine && lesserColumn { - return true - } - return false -} diff --git a/vendor/github.com/graphql-go/graphql/gqlerrors/syntax.go b/vendor/github.com/graphql-go/graphql/gqlerrors/syntax.go deleted file mode 100644 index abad6ade..00000000 --- a/vendor/github.com/graphql-go/graphql/gqlerrors/syntax.go +++ /dev/null @@ -1,69 +0,0 @@ -package gqlerrors - -import ( - "fmt" - "regexp" - "strings" - - "github.com/graphql-go/graphql/language/ast" - "github.com/graphql-go/graphql/language/location" - "github.com/graphql-go/graphql/language/source" -) - -func NewSyntaxError(s *source.Source, position int, description string) *Error { - l := location.GetLocation(s, position) - return NewError( - fmt.Sprintf("Syntax Error %s (%d:%d) %s\n\n%s", s.Name, l.Line, l.Column, description, highlightSourceAtLocation(s, l)), - []ast.Node{}, - "", - s, - []int{position}, - nil, - ) -} - -// printCharCode here is slightly different from lexer.printCharCode() -func printCharCode(code rune) string { - // print as ASCII for printable range - if code >= 0x0020 { - return fmt.Sprintf(`%c`, code) - } - // Otherwise print the escaped form. e.g. `"\\u0007"` - return fmt.Sprintf(`\u%04X`, code) -} -func printLine(str string) string { - strSlice := []string{} - for _, runeValue := range str { - strSlice = append(strSlice, printCharCode(runeValue)) - } - return fmt.Sprintf(`%s`, strings.Join(strSlice, "")) -} -func highlightSourceAtLocation(s *source.Source, l location.SourceLocation) string { - line := l.Line - prevLineNum := fmt.Sprintf("%d", (line - 1)) - lineNum := fmt.Sprintf("%d", line) - nextLineNum := fmt.Sprintf("%d", (line + 1)) - padLen := len(nextLineNum) - lines := regexp.MustCompile("\r\n|[\n\r]").Split(string(s.Body), -1) - var highlight string - if line >= 2 { - highlight += fmt.Sprintf("%s: %s\n", lpad(padLen, prevLineNum), printLine(lines[line-2])) - } - highlight += fmt.Sprintf("%s: %s\n", lpad(padLen, lineNum), printLine(lines[line-1])) - for i := 1; i < (2 + padLen + l.Column); i++ { - highlight += " " - } - highlight += "^\n" - if line < len(lines) { - highlight += fmt.Sprintf("%s: %s\n", lpad(padLen, nextLineNum), printLine(lines[line])) - } - return highlight -} - -func lpad(l int, s string) string { - var r string - for i := 1; i < (l - len(s) + 1); i++ { - r += " " - } - return r + s -} |