It would be nice to be able to reformat error in errorHandler. It's useful when you need to modify error before sending to client, for example:
- translate
Internal server error message to other language
- catch internal db error, expose it with a nice message
The api might be as simple as:
function formatError(error) {
// do something with error
}
errorHandler(formatError)
I keep hitting this actually simple cases where I just want to format my errors before sending them to client and current errorHandler is too restrictive in what I can do. However, I'm trying to avoid writing custom middleware instead of errorHandler and struggling to find solutions.
@jaydenseric help 🙏
It would be nice to be able to reformat error in
errorHandler. It's useful when you need to modify error before sending to client, for example:Internal server errormessage to other languageThe api might be as simple as:
I keep hitting this actually simple cases where I just want to format my errors before sending them to client and current
errorHandleris too restrictive in what I can do. However, I'm trying to avoid writing custom middleware instead oferrorHandlerand struggling to find solutions.@jaydenseric help 🙏