Skip to content

Commit

Permalink
convert non-error exception to error objects
Browse files Browse the repository at this point in the history
  • Loading branch information
kabeaty committed Oct 9, 2024
1 parent f2b588d commit b9d5524
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/src/core/server/services/errors/sentry/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ export class SentryErrorReporter extends ErrorReporter {
}

// Get the original cause of the error in case that it is wrapped.
const errorToReport = getErrorToReport(err as Error);
let errorToReport = getErrorToReport(err as Error);

if (!(errorToReport instanceof Error)) {
errorToReport = new Error(
"Non-error thrown: " + JSON.stringify(errorToReport)
);
}

// Capture and report the error to Sentry.
const id = Sentry.captureException(errorToReport, context);
Expand Down

0 comments on commit b9d5524

Please sign in to comment.