Filtering exception messages #3574
-
Strawberry catches all exceptions and returns the message to the client as a GraphQL error. This is not always desirable, as some error messages may be for internal use, and a generic error message should be returned instead. In my application I have a base exception class for errors that should be returned to users. All other errors should return a generic error message such as "an unexpected error occurred" (and be logged to Sentry so we can investigate and fix them, as it is already the case). Is there an easy way to do this with Strawberry? If not, would it make sense to add one? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @catwell, we typically recommend extensions for that. For hiding exceptions we have one built-in extension and an example in our documents on how to hide only specific exceptions. Both are described on this page: https://strawberry.rocks/docs/extensions/mask-errors |
Beta Was this translation helpful? Give feedback.
Hi @catwell, we typically recommend extensions for that. For hiding exceptions we have one built-in extension and an example in our documents on how to hide only specific exceptions. Both are described on this page: https://strawberry.rocks/docs/extensions/mask-errors