gqlerrors

package
v0.0.0-...-78b1151 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldASTsToNodeASTs

func FieldASTsToNodeASTs(fieldASTs []*ast.Field) []ast.Node

Types

type Error

type Error struct {
	Type          ErrorType
	Message       string
	Stack         string
	Nodes         []ast.Node
	Source        *source.Source
	Positions     []int
	Locations     []location.SourceLocation
	OriginalError error
}

Error is a structured error.

func NewError

func NewError(typ ErrorType, message string, nodes []ast.Node, stack string, source *source.Source, positions []int, origError error) *Error

NewError returns a new structured error.

func NewSyntaxError

func NewSyntaxError(s *source.Source, position int, description string) *Error

func (Error) Error

func (g Error) Error() string

Error implements Golang's built-in `error` interface

type ErrorType

type ErrorType string

ErrorType is a category type for an error.

const (
	ErrorTypeBadQuery     ErrorType = "BAD_QUERY"
	ErrorTypeInternal     ErrorType = "INTERNAL"
	ErrorTypeInvalidInput ErrorType = "INVALID_INPUT"
	ErrorTypeSyntax       ErrorType = "SYNTAX"
)

Well defined error types

type FormattedError

type FormattedError struct {
	Message       string                    `json:"message"`
	Type          ErrorType                 `json:"type,omitempty"`
	UserMessage   string                    `json:"userMessage,omitempty"`
	Locations     []location.SourceLocation `json:"locations"`
	StackTrace    string                    `json:"-"`
	OriginalError error                     `json:"-"`
}

func FormatError

func FormatError(err error) FormattedError

func FormatErrors

func FormatErrors(errs ...error) []FormattedError

func FormatPanic

func FormatPanic(r any) FormattedError

func NewFormattedError

func NewFormattedError(message string) FormattedError

func (FormattedError) Error

func (g FormattedError) Error() string

type FormattedErrors

type FormattedErrors []FormattedError

func (FormattedErrors) Len

func (errs FormattedErrors) Len() int

func (FormattedErrors) Less

func (errs FormattedErrors) Less(i, j int) bool

func (FormattedErrors) Swap

func (errs FormattedErrors) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL