diff --git a/src/app/error.tsx b/src/app/error.tsx index 42bae866..59b0c4af 100644 --- a/src/app/error.tsx +++ b/src/app/error.tsx @@ -1,6 +1,7 @@ 'use client'; + import React, { useEffect } from 'react'; -import { UserFriendlyErrorDisplay } from '@/components/errors/UserFriendlyErrorDisplay'; +import UserFriendlyErrorDisplay from '@/components/errors/UserFriendlyErrorDisplay'; import { errorReportingService } from '@/services/errorReporting'; export default function ErrorBoundary({ @@ -11,7 +12,6 @@ export default function ErrorBoundary({ reset: () => void; }) { useEffect(() => { - // Log the error to an error reporting service errorReportingService.addBreadcrumb('error.tsx', { errorMessage: error.message, digest: error.digest, @@ -25,9 +25,10 @@ export default function ErrorBoundary({ error={error} title="Something went wrong!" onRetry={reset} + // Only show stack traces in development showDetails={process.env.NODE_ENV === 'development'} severity="error" /> ); -} +} \ No newline at end of file diff --git a/src/components/errors/ErrorBoundarySystem.tsx b/src/components/errors/ErrorBoundarySystem.tsx index 90c3ee11..147eb8c6 100644 --- a/src/components/errors/ErrorBoundarySystem.tsx +++ b/src/components/errors/ErrorBoundarySystem.tsx @@ -17,6 +17,7 @@ export type ErrorBoundaryProps = { onError?: (error: Error, errorInfo: ErrorInfo) => void; isolationId?: string; isolationLevel?: string; + showDetails?: boolean; }; export class ErrorBoundarySystem extends Component { @@ -39,7 +40,6 @@ export class ErrorBoundarySystem extends Component ({ hasError: true, error, @@ -47,7 +47,6 @@ export class ErrorBoundarySystem extends Component

Something went wrong.

-

{this.state.error?.message}

+ {shouldShowDetails &&

{this.state.error?.message}

}
@@ -129,4 +132,4 @@ export function createErrorBoundary( return CustomErrorBoundary; } -export default ErrorBoundarySystem; +export default ErrorBoundarySystem; \ No newline at end of file