Express 5 · Error handling
Add an error handler
Define it last. It takes four arguments.
app.use((err, req, res, next) => {
console.error(err);
res.status(500).json({ error: "Internal Server Error" });
});
Official Express 5 documentation
Express 5 · Error handling
Define it last. It takes four arguments.
app.use((err, req, res, next) => {
console.error(err);
res.status(500).json({ error: "Internal Server Error" });
});
Official Express 5 documentation
Was this page helpful?