Skip to content

Add possibility to reformat error in errorHandler #10

@vladshcherbin

Description

@vladshcherbin

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 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions