2022-10-29 09:06:09 +00:00
|
|
|
import { captureException } from '@sentry/browser';
|
2022-06-18 08:35:51 +00:00
|
|
|
import { FallbackProps } from 'react-error-boundary';
|
2023-02-24 08:12:21 +00:00
|
|
|
import { useDebugState } from '@sd/client';
|
2023-01-20 03:32:35 +00:00
|
|
|
import { Button } from '@sd/ui';
|
2022-06-18 08:35:51 +00:00
|
|
|
|
2023-02-28 05:29:48 +00:00
|
|
|
export default ({ error, resetErrorBoundary }: FallbackProps) => (
|
|
|
|
<ErrorPage
|
|
|
|
message={error.message}
|
|
|
|
sendReportBtn={() => {
|
|
|
|
captureException(error);
|
|
|
|
resetErrorBoundary();
|
|
|
|
}}
|
|
|
|
reloadBtn={resetErrorBoundary}
|
|
|
|
/>
|
|
|
|
);
|
2022-10-29 09:06:09 +00:00
|
|
|
|
2023-02-25 13:50:22 +00:00
|
|
|
export function ErrorPage({
|
|
|
|
reloadBtn,
|
|
|
|
sendReportBtn,
|
|
|
|
message
|
|
|
|
}: {
|
|
|
|
reloadBtn?: () => void;
|
|
|
|
sendReportBtn?: () => void;
|
|
|
|
message: string;
|
|
|
|
}) {
|
2023-02-24 08:12:21 +00:00
|
|
|
const debug = useDebugState();
|
|
|
|
|
2022-06-18 08:35:51 +00:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
data-tauri-drag-region
|
|
|
|
role="alert"
|
2023-02-16 07:04:19 +00:00
|
|
|
className="border-app-divider bg-app flex h-screen w-screen flex-col items-center justify-center rounded-lg border p-4"
|
2022-06-18 08:35:51 +00:00
|
|
|
>
|
2023-02-16 07:04:19 +00:00
|
|
|
<p className="text-ink-faint m-3 text-sm font-bold">APP CRASHED</p>
|
|
|
|
<h1 className="text-ink text-2xl font-bold">We're past the event horizon...</h1>
|
2023-02-25 13:50:22 +00:00
|
|
|
<pre className="text-ink m-2">Error: {message}</pre>
|
2023-02-24 08:12:21 +00:00
|
|
|
{debug.enabled && (
|
|
|
|
<pre className="text-ink-dull m-2 text-sm">
|
|
|
|
Check the console (CMD/CRTL + OPTION + i) for stack trace.
|
|
|
|
</pre>
|
|
|
|
)}
|
2023-02-16 07:04:19 +00:00
|
|
|
<div className="text-ink flex flex-row space-x-2">
|
2023-02-25 13:50:22 +00:00
|
|
|
{reloadBtn && (
|
|
|
|
<Button variant="accent" className="mt-2" onClick={reloadBtn}>
|
|
|
|
Reload
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
{sendReportBtn && (
|
|
|
|
<Button variant="gray" className="mt-2" onClick={sendReportBtn}>
|
|
|
|
Send report
|
|
|
|
</Button>
|
|
|
|
)}
|
2022-06-18 08:35:51 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|