mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-08-31 16:49:24 +00:00
Added Error Boundary (#649)
* Added Error Boundary * Test improvements * Introduced useDevLogger * Updated Cypress to latest and aligned the tests * Added eslint-enable * Set allowCypressEnv: false for security reasons.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import type { FallbackProps } from "react-error-boundary";
|
||||
import GlobalErrorModal from "../modal/GlobalErrorModal";
|
||||
import { useDevLogger } from "../../hooks/useDevLogger";
|
||||
|
||||
/**
|
||||
* Error fallback component for React Error Boundary
|
||||
* Uses the existing GlobalErrorModal for consistent error display
|
||||
* @param error - The error that was caught
|
||||
* @param resetErrorBoundary - Function to reset the error boundary state
|
||||
*/
|
||||
const ErrorFallback = ({ error, resetErrorBoundary }: FallbackProps) => {
|
||||
useDevLogger(error);
|
||||
|
||||
const handleClose = () => {
|
||||
// Reset the error boundary to allow the component tree to re-render
|
||||
resetErrorBoundary();
|
||||
};
|
||||
|
||||
return (
|
||||
<GlobalErrorModal
|
||||
isOpen={true}
|
||||
onClose={handleClose}
|
||||
titleText="Application Error"
|
||||
contentText={
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "An unexpected error occurred. Please try again."
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default ErrorFallback;
|
||||
Reference in New Issue
Block a user