Add HandledGraphQLError that does not log an exception #228
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
I'm trying to send a custom error message in a web response. I can raise an exception to do that but I'm also getting sentry reports that I don't want.
In a Django project Sentry is setup to handle logging. When graphql-core logs this exception I get a sentry report.
https://github.com/graphql-python/graphql-core/blob/9202021fc87db9c175e115016cd53e5d9d085ac6/graphql/execution/executor.py#L446-L455
I want to be able to prevent the sentry report.
To send a custom error message back to the user you would just
raise HandledGraphQLError(msg)
.Here is the Django logging config for reference. Let me know if there is a better solution.