gqlerrors

package
v0.41.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package gqlerrors is a wrapper to define custom errors for the GraphQL server

Index

Constants

View Source
const (
	// NotFoundErrorCode is the error code for not found errors
	NotFoundErrorCode = "NOT_FOUND"
	// ValidationErrorCode is the error code for validation errors
	ValidationErrorCode = "VALIDATION_ERROR"
	// ConflictErrorCode is the error code for conflict errors
	ConflictErrorCode = "CONFLICT"
	// InternalServerErrorCode is the error code for internal server errors
	InternalServerErrorCode = "INTERNAL_SERVER_ERROR"
	// UnauthorizedErrorCode is the error code for unauthorized errors
	UnauthorizedErrorCode = "UNAUTHORIZED"
	// AlreadyExistsErrorCode is the error code for already exists errors
	AlreadyExistsErrorCode = "ALREADY_EXISTS"
	// MaxAttemptsErrorCode is the error code for max attempts errors
	MaxAttemptsErrorCode = "MAX_ATTEMPTS"
	// BadRequestErrorCode is the error code for bad request errors
	BadRequestErrorCode = "BAD_REQUEST"
	// NoAccessToModule is the error code for when an org has no access to a
	// specific schema and module
	NoAccessToModule = "MODULE_NO_ACCESS"
)

Error code constants

View Source
const (
	// ExtensionCodeKey is the key for the error code in the extensions
	ExtensionCodeKey = "code"
	// ExtensionMessageKey is the key for the error message in the extensions
	ExtensionMessageKey = "message"
	// ExtensionModuleKey is the key for the module that is required to get access to
	// the feature behind the graphql query
	ExtensionModuleKey = "module"
)

Variables

This section is empty.

Functions

func ErrorPresenter

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

ErrorPresenter is a custom error presenter for the GraphQL server

Types

type CustomError

type CustomError struct {
	// contains filtered or unexported fields
}

CustomError is a struct that implements the CustomErrorType interface

func NewCustomError

func NewCustomError(code, message string, err error) CustomError

NewCustomError creates a new CustomError with the given code and error

func NewCustomErrorWithModule added in v0.28.0

func NewCustomErrorWithModule(code, message string, err error, module *models.OrgModule) CustomError

NewCustomErrorWithModule creates a custom error with the given code, error and module

func (CustomError) Code

func (e CustomError) Code() string

Code satisfies the CustomErrorType interface

func (CustomError) Error

func (e CustomError) Error() string

Error satisfies the CustomErrorType interface

func (CustomError) Message

func (e CustomError) Message() string

Message satisfies the CustomErrorType interface

func (CustomError) Module added in v0.28.0

func (e CustomError) Module() models.OrgModule

Module satisfies the CustomError interface

type CustomErrorType

type CustomErrorType interface {
	error
	// Code returns the static error code for the error in the gql extensions
	Code() string
	// Message returns the detailed error message for the error in the gql extensions
	Message() string
	// Module returns the module that failed checks for the query to succeed
	Module() models.OrgModule
}

CustomErrorType is an interface that defines a custom error type

Jump to

Keyboard shortcuts

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