+ Let's Cube stopped unexpectedly.
+ If you have a saved result, it remains on this device. Reload the app to recover.
+
+
+ );
+ }
+}
+
+ErrorBoundary.propTypes = {
+ children: PropTypes.node.isRequired,
+ onReload: PropTypes.func,
+ reportError: PropTypes.func,
+};
+
+ErrorBoundary.defaultProps = {
+ onReload: () => window.location.reload(),
+ // The browser console is the only error sink configured in this client.
+ // eslint-disable-next-line no-console
+ reportError: (error, details) => console.error(error, details),
+};
+
+export default ErrorBoundary;
diff --git a/client/src/components/ErrorBoundary.test.jsx b/client/src/components/ErrorBoundary.test.jsx
new file mode 100644
index 0000000..a4763c6
--- /dev/null
+++ b/client/src/components/ErrorBoundary.test.jsx
@@ -0,0 +1,23 @@
+import React from 'react';
+import { fireEvent, render, screen } from '@testing-library/react';
+import ErrorBoundary from './ErrorBoundary';
+
+const Broken = () => {
+ throw new Error('render failed');
+};
+
+it('offers a reload action after a render failure', () => {
+ const onReload = jest.fn();
+ const reportError = jest.fn();
+
+ render(
+