I'd like to make sure error details are never sent out in responses from my restify-powered API. The best way to achieve that seemed to be via wrapping server.formatters in another function which filtered-out Errors before passing the transformed body on to the relevant formatter. I've probably missed some more obvious way to achieve this, but here's what I came up with. Does this seem reasonable, or is there a simpler solution?const server = restify.createServer()// wraps all formatters in a function filtering out Error bodiesObject.keys(server.formatters).forEach((name) => {  const formatter = server.formatters[ name ]  server.formatters[ name ] = (req, res, body, next) => {    // keep possibly sensitive details from going out in error messages    if (body instanceof Error &&      !(body instanceof errors.HttpError) &&      !(body instanceof errors.RestError)    ) {      body = new errors.InternalServerError('Internal Server Error')    }    return formatter(req, res, body, next)  }})
Keeping error details out of responses (Restify)
javascript;node.js;error handling