blob: 030f6ba11eef1e1c2f45b9fe96990bb306935917 (
plain)
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
|
import { FunctionComponent, useMemo } from "react";
import {
Anchor,
Box,
Button,
Center,
Code,
Container,
Group,
Text,
Title,
} from "@mantine/core";
import { faDizzy } from "@fortawesome/free-regular-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { GithubRepoRoot } from "@/constants";
import { Reload } from "@/utilities";
const Placeholder = "********";
interface Props {
error: Error;
}
const UIError: FunctionComponent<Props> = ({ error }) => {
const stack = useMemo(() => {
let callStack = error.stack ?? "";
// Remove sensitive information from the stack
callStack = callStack.replaceAll(window.location.host, Placeholder);
return callStack;
}, [error.stack]);
return (
<Container my="lg">
<Center>
<Title>
<Box component="span" mr="md">
<FontAwesomeIcon icon={faDizzy}></FontAwesomeIcon>
</Box>
<Text component="span" inherit>
Oops! UI is crashed!
</Text>
</Title>
</Center>
<Center my="xl">
<Code>{stack}</Code>
</Center>
<Group justify="center">
<Anchor href={`${GithubRepoRoot}/issues/new/choose`} target="_blank">
<Button color="yellow">Report Issue</Button>
</Anchor>
<Button onClick={Reload}>Reload Page</Button>
</Group>
</Container>
);
};
export default UIError;
|