Documentation
¶
Index ¶
- Constants
- func ErrCode(gqlErr *gqlerror.Error) string
- func ErrorPresenter(ctx context.Context, err error) *gqlerror.Error
- func HasErrCode(errs *gqlerror.List, code string) bool
- func IsErrCode(err error, code string) bool
- func NewBadRequestError(ctx context.Context, err error) *gqlerror.Error
- func NewBadRequestErrorWithMsg(ctx context.Context, err error, message string) *gqlerror.Error
- func NewErrorWithMsg(ctx context.Context, err error, message string, code string) *gqlerror.Error
- func NewInternalErrorWithMsg(ctx context.Context, err error, message string) *gqlerror.Error
- func NewUnauthorizedError(ctx context.Context, err error) *gqlerror.Error
- func NewUnauthorizedErrorWithMsg(ctx context.Context, err error, message string) *gqlerror.Error
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 = "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 ¶
ErrCode returns the code of the gqlerror.Error If the code is not correctly set, it returns an empty string.
func ErrorPresenter ¶
ErrorPresenter is a custom error presenter that logs the error and returns a gqlerror.Error.
func HasErrCode ¶
HasErrCode checks if the gqlerror.List contains an error with the given code.
func NewBadRequestError ¶
NewBadRequestError creates a new bad request error.
func NewBadRequestErrorWithMsg ¶
NewBadRequestErrorWithMsg creates a new bad request error with a message.
func NewErrorWithMsg ¶
NewErrorWithMsg creates a new gqlerror.Error with a message and code.
func NewInternalErrorWithMsg ¶
NewInternalErrorWithMsg creates a new internal server error with a message.
func NewUnauthorizedError ¶
NewUnauthorizedError creates a new unauthorized error.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.