Improve UI error view

pull/1867/head v1.0.5-beta.22
LASER-Yi 2 years ago
parent 51d1c46b18
commit 0e7c5410d4

@ -7,18 +7,30 @@ import {
Box,
Button,
Center,
Code,
Container,
Group,
Text,
Title,
} from "@mantine/core";
import { FunctionComponent } from "react";
import { FunctionComponent, useMemo } from "react";
const Placeholder = "********";
interface Props {
error: Error;
}
const UIError: FunctionComponent<Props> = ({ error }) => (
const UIError: FunctionComponent<Props> = ({ error }) => {
const stack = useMemo(() => {
let callStack = error.stack ?? "";
// Remove sensitive information from the stack
callStack = callStack.replaceAll(window.location.hostname, Placeholder);
return callStack;
}, [error.stack]);
return (
<Container my="lg">
<Center>
<Title>
@ -30,8 +42,8 @@ const UIError: FunctionComponent<Props> = ({ error }) => (
</Text>
</Title>
</Center>
<Center>
<Text mb="lg">{error.message}</Text>
<Center my="xl">
<Code>{stack}</Code>
</Center>
<Group position="center">
<Anchor href={`${GithubRepoRoot}/issues/new/choose`} target="_blank">
@ -42,6 +54,7 @@ const UIError: FunctionComponent<Props> = ({ error }) => (
</Button>
</Group>
</Container>
);
);
};
export default UIError;

Loading…
Cancel
Save