import { Component, JSX, createSignal, ErrorBoundary as SolidErrorBoundary } from 'solid-js';
import { logError } from '@/utils/logger';
import { SectionHeader } from '@/components/shared/SectionHeader';
interface ErrorBoundaryProps {
children: JSX.Element;
fallback?: (error: Error, reset: () => void) => JSX.Element;
onError?: (error: Error) => void;
}
const DefaultErrorFallback: Component<{ error: Error; reset: () => void }> = (props) => {
const [details, setDetails] = createSignal(false);
return (
Please try again or reload the page. If the problem persists, contact your administrator.
Technical details are suppressed in this view. Check server logs for full context.
);
};
export const ErrorBoundary: Component = (props) => {
return (
{
// Log the error
logError('Error boundary caught error', error);
// Call custom error handler if provided
if (props.onError) {
props.onError(error);
}
// Render custom or default fallback
if (props.fallback) {
return props.fallback(error, reset);
}
return ;
}}
>
{props.children}
);
};
// Component-specific error boundary with more context
export const ComponentErrorBoundary: Component<{
name: string;
children: JSX.Element;
}> = (props) => {
return (
(
)}
onError={(error) => {
logError(`Error in component ${props.name}`, error);
}}
>
{props.children}
);
};