Created
August 29, 2022 15:34
-
-
Save KolbySisk/b371fcd55eb272f7feaf1c365ccbafd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Middleware } from 'next-api-route-middleware'; | |
export const captureErrors: Middleware = async (req, res, next) => { | |
try { | |
await next(); | |
} catch (error) { | |
console.error(error); | |
Sentry.captureException(error); | |
res.status(500).send({ message: 'Server error!' }); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment