Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace files
go.work*
17 changes: 9 additions & 8 deletions errorhandling/error_handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import (

var (
errorCodeMappings = map[errors.ErrorCode]string{
errors.InternalError: "INTERNAL_ERROR",
errors.NotFound: "NOT_FOUND",
errors.InvalidArgument: "INVALID_ARGUMENT",
errors.Unauthenticated: "UNAUTHENTICATED",
errors.PermissionDenied: "PERMISSION_DENIED",
errors.Unknown: "UNKNOWN",
errors.InternalError: "INTERNAL_ERROR",
errors.NotFound: "NOT_FOUND",
errors.InvalidArgument: "INVALID_ARGUMENT",
errors.Unauthenticated: "UNAUTHENTICATED",
errors.PermissionDenied: "PERMISSION_DENIED",
errors.UnprocessableContent: "UNPROCESSABLE_CONTENT",
errors.Unknown: "UNKNOWN",
}
)

Expand Down Expand Up @@ -48,7 +49,7 @@ func ConfigureErrorPresenterFunc(reporterFunc ErrorReporterFunc) graphql.ErrorPr
reportAndLogError(reporterFunc, ctx, customError)

err.Message = errors.DisplayMessage(customError)
err.Extensions = map[string]interface{}{
err.Extensions = map[string]any{
"code": transformToGraphqlErrorCode(errors.Code(customError)),
}
return err
Expand All @@ -57,7 +58,7 @@ func ConfigureErrorPresenterFunc(reporterFunc ErrorReporterFunc) graphql.ErrorPr

// ConfigureRecoverFunc will better handle panic errors and recover from it
func ConfigureRecoverFunc() graphql.RecoverFunc {
return func(_ context.Context, errInterface interface{}) error {
return func(_ context.Context, errInterface any) error {
var err error
switch e := errInterface.(type) {
case error:
Expand Down