Skip to content

Commit

Permalink
graphql error code addition
Browse files Browse the repository at this point in the history
Signed-off-by: Rajshekar Chavakula <[email protected]>
  • Loading branch information
chavakula committed Feb 6, 2024
1 parent 2df7fbd commit e133e88
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/apid/actions/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const (
// the operation has completed successfully. For example, a successful
// response from a server could have been delayed long
DeadlineExceeded

// Threshold set in config reached. These settings are done in config of backend.yaml
ThresholdReached
)

// Default error messages if not message is provided.
Expand All @@ -65,6 +68,7 @@ var standardErrorMessages = map[ErrCode]string{
PaymentRequired: "license required",
PreconditionFailed: "precondition failed",
DeadlineExceeded: "deadline exceeded",
ThresholdReached: "Threshold reached",
}

// Error describes an issue that ocurred while performing the action.
Expand Down
2 changes: 2 additions & 0 deletions backend/apid/graphql/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func newStdErr(input string, err error) stdErr {
out.code = schema.ErrCodes.ERR_ALREADY_EXISTS
case (*store.ErrNotFound):
out.code = schema.ErrCodes.ERR_NOT_FOUND
case (*store.ErrThreshold):
out.code = schema.ErrCodes.ERR_THRESHOLD_REACHED
}
return out
}
Expand Down
8 changes: 8 additions & 0 deletions backend/apid/graphql/schema/errors.gql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions backend/apid/graphql/schema/errors.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,10 @@ enum ErrCode {
permissions.
"""
ERR_PERMISSION_DENIED

"""
Indicates that set thresholds in configured have reached
"""
ERR_THRESHOLD_REACHED

}

0 comments on commit e133e88

Please sign in to comment.