Lumi icon indicating copy to clipboard operation
Lumi copied to clipboard

refactor(error-handler): pipe error-responses through error-middleware

Open JPSchellenberg opened this issue 3 years ago • 3 comments

This change makes the server conform with the express-style to handle errrors: https://expressjs.com/en/guide/error-handling.html It adds a central errorHandler middleware at the end of the middleware-chain, which is called when a handler calls the next(error) function with an argument. (Usually an error) This allows us to remove quite a lot sentry imports and it provides a central place to send back an error.

JPSchellenberg avatar Sep 29 '21 16:09 JPSchellenberg

Without having had a closer look:

The new approach should allow customizing the Sentry report so that the error titles are more helpful and aggregate correctly. E.g. they shouldn't contain specific paths in the title that prevent aggregation. This is a serious drawback in the current way error reports work. You have to make sure the generic error handler doesn't prevent this.

sr258 avatar Sep 30 '21 05:09 sr258

Yes, I have that in mind. The most important aspect of this change is to have a standardised error-response for the client with a traceable error-code.

JPSchellenberg avatar Sep 30 '21 15:09 JPSchellenberg

Does it make sense to send the error to Sentry from the client or couldn't we already send it to from the server together with all stack traces etc.?

sr258 avatar Sep 30 '21 15:09 sr258