diff --git a/src/custom/ErrorBoundary/ErrorBoundary.tsx b/src/custom/ErrorBoundary/ErrorBoundary.tsx
index 51345307..a47c3e8c 100644
--- a/src/custom/ErrorBoundary/ErrorBoundary.tsx
+++ b/src/custom/ErrorBoundary/ErrorBoundary.tsx
@@ -20,6 +20,8 @@ const StyledLink = styled(Link)(({ theme }) => ({
}));
const CodeMessage = styled('div')(({ theme }) => ({
+ display: 'flex',
+ flexDirection: 'column',
backgroundColor: theme.palette.background.code,
color: theme.palette.text.tertiary,
padding: '.85rem',
@@ -30,14 +32,32 @@ const CodeMessage = styled('div')(({ theme }) => ({
interface FallbackComponentProps extends FallbackProps {
resetErrorBoundary: () => void;
children?: React.ReactNode;
+ pageUrl?: string;
+ timestamp?: string;
+ showPackageInfo?: boolean;
+ version?: string;
}
-export function Fallback({ error, children }: FallbackComponentProps): JSX.Element {
+export function Fallback({
+ error,
+ children,
+ showPackageInfo,
+ version
+}: FallbackComponentProps): JSX.Element {
return (
Uh-oh!😔 Please pardon the mesh.
- {(error as Error).message}
+
+ Error:
+ {(error as Error).message}
+
+
+ {showPackageInfo && (
+ <>
+ Version: {version}
+ >
+ )}
We apologize for the inconvenience. The issue may be on our end. If troubleshooting doesn't
@@ -56,18 +76,50 @@ export function Fallback({ error, children }: FallbackComponentProps): JSX.Eleme
}
const reportError = (error: Error, info: React.ErrorInfo): void => {
+ const pageUrl = window.location.href;
+ const timestamp = new Date().toLocaleString();
// This is where you'd send the error to Sentry, etc
- console.log('Error Caught Inside Boundary --reportError', error, 'Info', info);
+ console.log(
+ 'Error Caught Inside Boundary --reportError',
+ error,
+ 'Info',
+ info,
+ 'Page URL:',
+ pageUrl,
+ 'Timestamp:',
+ timestamp
+ );
};
interface ErrorBoundaryProps {
customFallback?: React.ComponentType;
children: React.ReactNode;
+ onErrorCaught?: (error: string) => void;
}
-export const ErrorBoundary: React.FC = ({ customFallback, children }) => {
+export const ErrorBoundary: React.FC = ({
+ customFallback,
+ children,
+ onErrorCaught
+}) => {
+ const pageUrl = window.location.href;
+ const timestamp = new Date().toLocaleString();
+
+ const handleError = (error: Error, info: React.ErrorInfo) => {
+ // Pass error message to onErrorCaught
+ onErrorCaught?.(error.message);
+ reportError(error, info);
+ };
+
return (
-
+
+ }
+ onError={handleError}
+ >
{children}
);