-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathCapErrorBoundary.tsx
More file actions
60 lines (58 loc) · 1.69 KB
/
Copy pathCapErrorBoundary.tsx
File metadata and controls
60 lines (58 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { Button } from "@cap/ui-solid";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
import { ErrorBoundary, type ParentProps } from "solid-js";
export function CapErrorBoundary(props: ParentProps) {
return (
<ErrorBoundary
fallback={(e: Error) => {
console.error(e);
return (
<div class="w-full h-full flex flex-col justify-center items-center bg-gray-2 border-gray-3 max-h-screen overflow-hidden transition-[border-radius] duration-200 text-(--text-secondary) gap-y-4 max-sm:gap-y-2 px-8 text-center">
<IconCapLogo class="max-sm:size-16" />
<h1 class="text-(--text-primary) text-3xl max-sm:text-xl font-bold">
An Error Occured
</h1>
<p class="mb-2 max-sm:text-sm">
We're very sorry, but something has gone wrong.
</p>
<div class="flex flex-row gap-4 max-sm:flex-col max-sm:gap-2">
<Button
onClick={() => {
writeText(`${e.toString()}\n\n${e.stack}`);
}}
>
Copy Error to Clipboard
</Button>
<Button
onClick={() => {
location.reload();
}}
variant="gray"
>
Reload
</Button>
<Button
onClick={() => getCurrentWebviewWindow().close()}
variant="destructive"
>
Close
</Button>
</div>
{import.meta.env.DEV && (
<div class="h-0 text-sm">
<pre class="text-left mt-8">{`${e.toString()}\n\n${e.stack
?.toString()
.split("\n")
.slice(0, 10)
.join("\n")}`}</pre>
</div>
)}
</div>
);
}}
>
{props.children}
</ErrorBoundary>
);
}