Skip to content

Commit

Permalink
chore: Add dynamic import and trigger captureException (#15583)
Browse files Browse the repository at this point in the history
  • Loading branch information
emrysal authored Jun 26, 2024
1 parent 6632c26 commit f259994
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/lib/server/defaultResponder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit f259994

Please sign in to comment.