title: Always return JSON data from ExpressJS default error handler
body: <p>I am building an API server using ExpressJS. I want to ensure that the server always responds with JSON data rather than HTML data. For all the custom routes that I define, I can make the server respond with JSON data.</p>
  
  <p>But in case of errors like "Page not found (404)" or "Internal Server Error (500)" the server responds with HTML content. Is there any inbuild configuration settings that allow making these responses in JSON format?</p>
  
  <p>I can define custom error handlers for this, but I wish to use the features of inbuild error handler like hiding stack trace based on NODE_ENV.</p>