Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle query runner errors #6424

Merged
merged 4 commits into from
Jul 27, 2024
Merged

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Jul 26, 2024

  • Throw service error from query runner
  • Catch in resolver factories
  • Map to graphql errors

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request introduces comprehensive error handling improvements for the query runner, ensuring service-specific exceptions are mapped to GraphQL errors.

  • Enhanced Error Handling: Replaced generic exceptions with WorkspaceQueryRunnerException across multiple files for more granular error control.
  • New Utility Function: Added workspace-query-runner-graphql-api-exception-handler.util.ts to map custom exceptions to GraphQL errors.
  • Custom Exception Class: Introduced workspace-query-runner.exception.ts to standardize error handling within the workspace query runner.
  • Resolver Updates: Modified resolver factories to catch and handle errors using the new exception handler utility.
  • GraphQL Config Update: Replaced useExceptionHandler with useGraphQLErrorHandlerHook in graphql-config.service.ts for improved error handling.

16 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

@@ -49,7 +58,7 @@ export const computePgGraphQLError = (
const errorMessage = error?.message;

const mappedErrorKey = Object.keys(pgGraphQLErrorMapping).find(
(key) => errorMessage?.startsWith(key),
(key) => errorMessage?.contains(key),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: Use of contains instead of startsWith for error message matching.

@thomtrp thomtrp changed the title Handle query runner errors [Not ready] Handle query runner errors Jul 26, 2024
@charlesBochet charlesBochet changed the title [Not ready] Handle query runner errors Handle query runner errors Jul 27, 2024
Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I've remove the unused hook and replaced string.contains by string.includes that seems more legit

@charlesBochet charlesBochet merged commit 3060eb4 into main Jul 27, 2024
6 checks passed
@charlesBochet charlesBochet deleted the tt-handle-errors-in-query-builder branch July 27, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants