The new logbot, not committed from the wrong terminal window this time.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
672 B

6 years ago
  1. package api
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. // A QueryError is a GraphQL error.
  7. type QueryError struct {
  8. Message string `json:"message"`
  9. Path []string `json:"path"`
  10. }
  11. func (err QueryError) Error() string {
  12. return fmt.Sprintf("GraphQL: %s: %s", strings.Join(err.Path, "."), err.Message)
  13. }
  14. func (err QueryError) String() string {
  15. return err.Error()
  16. }
  17. // QueryErrorList is a list of query errors
  18. type QueryErrorList []QueryError
  19. func (errs QueryErrorList) Error() string {
  20. if len(errs) == 1 {
  21. return errs[0].Error()
  22. }
  23. return fmt.Sprintf("%s (+%d others)", errs[0].Error(), len(errs)-1)
  24. }
  25. func (errs QueryErrorList) String() string {
  26. return errs.Error()
  27. }