Standardizing Express.js Error Handling with One Library
If you’ve been working with Express.js for a while, you know the struggle. You start a project, and soon your controllers look like this: // The “Bad” Way app.post(‘/users’, async (req, res) => { try { // … logic } catch (error) { console.error(error); if (error.code === ‘P2002’) { // Prisma unique constraint return res.status(400).json({…