Files
EpicNext-Cms/src/lib/report-error.ts
T
SimoandCursor 6b884ad25a
Local Build and Deploy / deploy (push) Successful in 1m42s
Harden deploy gates, prod AUTH_SECRET, and Sentry error reporting.
Align onlyBuiltDependencies with the workspace, fail fast without AUTH_SECRET in production, and delete catalog_items via VARCHAR-safe SQL so page deletes do not leave orphans.

Co-authored-by: Cursor <[email protected]>
2026-07-18 19:32:15 +02:00

19 lines
604 B
TypeScript

import * as Sentry from "@sentry/nextjs";
import { logger } from "@/lib/logger";
/**
* Log unexpected errors and forward them to Sentry when a DSN is configured.
* Domain errors (validation, auth, etc.) should NOT go through here.
*/
export function reportError(error: unknown, context = "Unhandled error"): void {
const message = error instanceof Error ? error.message : String(error);
logger.error(context, {
err: message,
name: error instanceof Error ? error.name : undefined,
});
if (process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN) {
Sentry.captureException(error);
}
}