diff --git a/packages/components/src/custom/ErrorBoundary.tsx b/packages/components/src/custom/ErrorBoundary.tsx index 556bbba3..294f869a 100644 --- a/packages/components/src/custom/ErrorBoundary.tsx +++ b/packages/components/src/custom/ErrorBoundary.tsx @@ -1,80 +1,84 @@ -//Commenting out the below code because its having typescript issues with using type as its violating the eslint rules and its failing workflow checks +import { Button } from '@mui/material'; +import React, { type FC } from 'react'; +import { + ErrorBoundaryProps, + FallbackProps, + ErrorBoundary as ReactErrorBoundary +} from 'react-error-boundary'; -// import { Button } from '@mui/material'; -// import React, { type FC } from 'react'; -// import { -// ErrorBoundaryProps, -// FallbackProps, -// ErrorBoundary as ReactErrorBoundary -// } from 'react-error-boundary'; +const Fallback: React.ComponentType = ({ error, resetErrorBoundary }) => { + if (error instanceof Error) { + // Check if error is an instance of Error + return ( +
+

Uh-oh!😔 Please pardon the mesh.

+
+ {error.message} +
+ +
+ ); + } else { + // Handle the case where error is not an instance of Error + return ( +
+

Uh-oh!😔 An unknown error occurred.

+ +
+ ); + } +}; -// const Fallback: React.ComponentType = ({ error, resetErrorBoundary }) => { -// if (error instanceof Error) { -// // Check if error is an instance of Error -// return ( -//
-//

Uh-oh!😔 Please pardon the mesh.

-//
-// {error.message} -//
-// -//
-// ); -// } else { -// // Handle the case where error is not an instance of Error -// return ( -//
-//

Uh-oh!😔 An unknown error occurred.

-// -//
-// ); -// } -// }; +const reportError = (error: Error, info: React.ErrorInfo) => { + // This is where you'd send the error to Sentry,etc + console.log('Error Caught Inside Boundary --reportError', error, 'Info', info); +}; -// const reportError = (error: Error, info: React.ErrorInfo) => { -// // This is where you'd send the error to Sentry,etc -// console.log('Error Caught Inside Boundary --reportError', error, 'Info', info); -// }; +export const ErrorBoundary: FC = ({ children, ...props }) => { + return ( + + {children} + + ); +}; +// +export const withErrorBoundary =

( + Component: React.ComponentType

, + errorHandlingProps: ErrorBoundaryProps | null +) => { + const WrappedWithErrorBoundary: React.FC

= (props: P) => ( + + + + ); -// export const ErrorBoundary: FC = ({ children, ...props }) => { -// return ( -// -// {children} -// -// ); -// }; -// // -// export const withErrorBoundary = ( -// Component: FC, -// errorHandlingProps: ErrorBoundaryProps | null -// ) => { -// const WrappedWithErrorBoundary = (props: any) => ( -// -// -// -// ); + return WrappedWithErrorBoundary; +}; -// return WrappedWithErrorBoundary; -// }; +interface Props { + children: React.ReactNode; +} -// export const withSuppressedErrorBoundary = (Component: React.ComponentType) => { -// const WrappedWithErrorBoundary = (props: any) => ( -// null}> -// -// -// ); +export const withSuppressedErrorBoundary =

( + Component: React.ComponentType

+) => { + const WrappedWithErrorBoundary: React.FC

= (props: P & Props) => ( + null}> + + + ); -// return WrappedWithErrorBoundary; -// }; + return WrappedWithErrorBoundary; +};