Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KolbySisk/b371fcd55eb272f7feaf1c365ccbafd4 to your computer and use it in GitHub Desktop.
Save KolbySisk/b371fcd55eb272f7feaf1c365ccbafd4 to your computer and use it in GitHub Desktop.
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