Error Handling

Add an error handling middleware to catch and respond to errors:

app.use((err, req, res, next) => {
  console.error(err.stack);
  res.status(500).send('Something broke!');
});

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *