errorhandler

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CodeUnknown is the code for when an error occurred before your server could attempt to parse the given GraphQL operation.
	CodeUnknown = "UNKNOWN"
	// CodeGraphQLParseFailed is the code for when the GraphQL operation string contains a syntax error.
	CodeGraphQLParseFailed = "GRAPHQL_PARSE_FAILED"
	// CodeGraphQLValidationFailed is the code for when the GraphQL operation is not valid against the server's schema.
	CodeGraphQLValidationFailed = "GRAPHQL_VALIDATION_FAILED"
	// CodeBadUserInput is the code for when the GraphQL operation includes an invalid value for a field argument.
	CodeBadUserInput = "BAD_USER_INPUT"
	// CodeBadRequest is the code for when an error occurred before your server could attempt to parse the given GraphQL operation.
	CodeBadRequest = "BAD_REQUEST"
	// CodeInternalServerError is the code for when an error occurred before your server could attempt to parse the given GraphQL operation.
	CodeInternalServerError = "INTERNAL_SERVER_ERROR"
	// CodeNotFound is the code for when a resource was not found.
	CodeNotFound = "NOT_FOUND"
	// CodeUnauthorized is the code for when a authentication is required and has failed or has not been provided.
	CodeUnauthorized = "UNAUTHORIZED"
	// CodeForbidden is the code for when a user is not authorized to access a resource.
	CodeForbidden = "FORBIDDEN"
	// CodeTooManyRequests is the code for when a user has made too many requests.
	CodeTooManyRequests = "TOO_MANY_REQUESTS"
)

Variables

This section is empty.

Functions

func ErrCode

func ErrCode(gqlErr *gqlerror.Error) string

ErrCode returns the code of the gqlerror.Error If the code is not correctly set, it returns an empty string.

func ErrorPresenter

func ErrorPresenter(ctx context.Context, err error) *gqlerror.Error

ErrorPresenter is a custom error presenter that logs the error and returns a gqlerror.Error.

func HasErrCode

func HasErrCode(errs *gqlerror.List, code string) bool

HasErrCode checks if the gqlerror.List contains an error with the given code.

func IsErrCode

func IsErrCode(err error, code string) bool

IsErrCode checks if the error is a gqlerror.Error and has the given code.

func NewBadRequestError

func NewBadRequestError(ctx context.Context, err error) *gqlerror.Error

NewBadRequestError creates a new bad request error.

func NewBadRequestErrorWithMsg

func NewBadRequestErrorWithMsg(ctx context.Context, err error, message string) *gqlerror.Error

NewBadRequestErrorWithMsg creates a new bad request error with a message.

func NewErrorWithMsg

func NewErrorWithMsg(ctx context.Context, err error, message string, code string) *gqlerror.Error

NewErrorWithMsg creates a new gqlerror.Error with a message and code.

func NewInternalErrorWithMsg

func NewInternalErrorWithMsg(ctx context.Context, err error, message string) *gqlerror.Error

NewInternalErrorWithMsg creates a new internal server error with a message.

func NewUnauthorizedError

func NewUnauthorizedError(ctx context.Context, err error) *gqlerror.Error

NewUnauthorizedError creates a new unauthorized error.

func NewUnauthorizedErrorWithMsg

func NewUnauthorizedErrorWithMsg(ctx context.Context, err error, message string) *gqlerror.Error

NewUnauthorizedErrorWithMsg creates a new unauthorized error with a message.

Types

This section is empty.

Jump to

Keyboard shortcuts

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