chore: Add dynamic import and trigger captureException (#15583)

This commit is contained in:
Alex van Andel
2024-06-26 22:32:26 +00:00
committed by GitHub
parent db60f8faed
commit 750676f91a
+4
View File
@@ -19,6 +19,10 @@ export function defaultResponder<T>(f: Handle<T>) {
} catch (err) {
console.error(err);
const error = getServerErrorFromUnknown(err);
// dynamic import of Sentry so it's only loaded when something goes wrong.
const captureException = (await import("@sentry/nextjs")).captureException;
captureException(err);
// return API route response
return res
.status(error.statusCode)
.json({ message: error.message, url: error.url, method: error.method });