You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Global exception filter extending base exception filter:
Call captureException in a global error handler that catches all unhandled exceptions (should work with an empty @Catch()decorator on the filter).
According to what I understood from the docs this approach should work just fine but it didn't. NestJS does not allow chaining of exception filters, so according to some rules exactly one exception filter is determined that will be called. The first filter that should be called is the most specific filter. However, this is not the case if introduced in the setupNestErrorHandler method. Rather, the global exception filter always overwrote user-defined global exception filters.
Interceptor:
Call captureException in a global interceptor.
The problem is that in nest interceptors are called before exception filters. So for example even if a user defines an exception filter to catch a specific exception type, the exception will still be logged to Sentry. So this approach kind of works, but is not really what we want, because it would produce a lot of noise for users.
Final solution:
Ported the existing code to a nestjs root module.
Initially just meant as a setup improvement (much more native to nest), but had the nice side-effect of working properly with user-defined local and global exception filters.
The text was updated successfully, but these errors were encountered:
nicohrubec
changed the title
Improve SDK error instrumentation. Improve error handler to avoid having to pass anything in. or alternatively, find a way as native to regular Nest.js usage as possible. At the very least investigate current problems and find ways to address them.
Improve SDK error instrumentation
Jul 4, 2024
nicohrubec
changed the title
Improve SDK error instrumentation
Improve NestJS SDK error instrumentation
Jul 4, 2024
Previous solution:
Sentry.setupNestErrorHandler()
in main file.captureException
call and then using the proxy as a global filter.Attempted updates:
captureException
in a global error handler that catches all unhandled exceptions (should work with an empty@Catch()
decorator on the filter).setupNestErrorHandler
method. Rather, the global exception filter always overwrote user-defined global exception filters.captureException
in a global interceptor.Final solution:
The text was updated successfully, but these errors were encountered: