mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-02-20 07:37:26 -05:00
* log to disk * remove some unwraps * panicless * some p2p error handling * clippy moment * Fix `<ErrorBoundary />` * open logs button * 39 to 0 * fix types * update deps and comment out broken tests * clippy * more clippy * upgrade rimraf - https://github.com/isaacs/rimraf/issues/259 * regen broken lockfile * update `notify` and update `commands.ts` * more clippy (pls work) * allow deprecated for p2p (hopefully temporary) * a * upgrade deps for p2p * do betterer * do it correctly * remove unused import * improve core startup error + bc keypair --------- Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com> Co-authored-by: brxken128 <77554505+brxken128@users.noreply.github.com>
81 lines
2.0 KiB
TypeScript
81 lines
2.0 KiB
TypeScript
import { captureException } from '@sentry/browser';
|
|
import { FallbackProps } from 'react-error-boundary';
|
|
import { useRouteError } from 'react-router';
|
|
import { useDebugState } from '@sd/client';
|
|
import { Button } from '@sd/ui';
|
|
import { useOperatingSystem } from './hooks';
|
|
|
|
export function RouterErrorBoundary() {
|
|
const error = useRouteError();
|
|
return (
|
|
<ErrorPage
|
|
message={(error as any).toString()}
|
|
sendReportBtn={() => {
|
|
captureException(error);
|
|
location.reload();
|
|
}}
|
|
reloadBtn={() => {
|
|
location.reload();
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default ({ error, resetErrorBoundary }: FallbackProps) => (
|
|
<ErrorPage
|
|
message={`Error: ${error.message}`}
|
|
sendReportBtn={() => {
|
|
captureException(error);
|
|
resetErrorBoundary();
|
|
}}
|
|
reloadBtn={resetErrorBoundary}
|
|
/>
|
|
);
|
|
|
|
export function ErrorPage({
|
|
reloadBtn,
|
|
sendReportBtn,
|
|
message,
|
|
submessage
|
|
}: {
|
|
reloadBtn?: () => void;
|
|
sendReportBtn?: () => void;
|
|
message: string;
|
|
submessage?: string;
|
|
}) {
|
|
const debug = useDebugState();
|
|
const os = useOperatingSystem();
|
|
const isMacOS = os === 'macOS';
|
|
|
|
if (!submessage && debug.enabled)
|
|
submessage = 'Check the console (CMD/CTRL + OPTION + i) for stack trace.';
|
|
|
|
return (
|
|
<div
|
|
data-tauri-drag-region
|
|
role="alert"
|
|
className={
|
|
'flex h-screen w-screen flex-col items-center justify-center border border-app-divider bg-app p-4' +
|
|
(isMacOS ? ' rounded-lg' : '')
|
|
}
|
|
>
|
|
<p className="m-3 text-sm font-bold text-ink-faint">APP CRASHED</p>
|
|
<h1 className="text-2xl font-bold text-ink">We're past the event horizon...</h1>
|
|
<pre className="m-2 text-ink">{message}</pre>
|
|
{submessage && <pre className="m-2 text-sm text-ink-dull">{submessage}</pre>}
|
|
<div className="flex flex-row space-x-2 text-ink">
|
|
{reloadBtn && (
|
|
<Button variant="accent" className="mt-2" onClick={reloadBtn}>
|
|
Reload
|
|
</Button>
|
|
)}
|
|
{sendReportBtn && (
|
|
<Button variant="gray" className="mt-2" onClick={sendReportBtn}>
|
|
Send report
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|