Skip to content

Issue with Sentry Error Handling in Express.js #1876

Answered by RobinTail
yuuri111 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @yuuri111 ,

Are you using createServer() method?

If so, the errorHandler you put into createConfig() is only used for the routing errors (when a route was not found). But the errors you throw from within your endpoints are handled by the corresponding ResultHandler of the EndpointsFactory that those endpoints were made on.

Also, the app.use you call, is called after the proprietary error handler is installed, so it does not make any effect.

You need to make a custom result handler, similar to what you already made using createResultHandler, but more comprehensive:

  • it should handle error by calling Sentry.captureException;
  • it should handle no error by sending the response.

Assuming…

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@RobinTail
Comment options

Answer selected by RobinTail
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@yuuri111
Comment options

@RobinTail
Comment options

@yuuri111
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants