mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-10 16:57:45 +08:00
Improve UI error view
This commit is contained in:
parent
51d1c46b18
commit
0e7c5410d4
1 changed files with 39 additions and 26 deletions
|
@ -7,18 +7,30 @@ import {
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
|
Code,
|
||||||
Container,
|
Container,
|
||||||
Group,
|
Group,
|
||||||
Text,
|
Text,
|
||||||
Title,
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { FunctionComponent } from "react";
|
import { FunctionComponent, useMemo } from "react";
|
||||||
|
|
||||||
|
const Placeholder = "********";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
error: Error;
|
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">
|
<Container my="lg">
|
||||||
<Center>
|
<Center>
|
||||||
<Title>
|
<Title>
|
||||||
|
@ -30,8 +42,8 @@ const UIError: FunctionComponent<Props> = ({ error }) => (
|
||||||
</Text>
|
</Text>
|
||||||
</Title>
|
</Title>
|
||||||
</Center>
|
</Center>
|
||||||
<Center>
|
<Center my="xl">
|
||||||
<Text mb="lg">{error.message}</Text>
|
<Code>{stack}</Code>
|
||||||
</Center>
|
</Center>
|
||||||
<Group position="center">
|
<Group position="center">
|
||||||
<Anchor href={`${GithubRepoRoot}/issues/new/choose`} target="_blank">
|
<Anchor href={`${GithubRepoRoot}/issues/new/choose`} target="_blank">
|
||||||
|
@ -43,5 +55,6 @@ const UIError: FunctionComponent<Props> = ({ error }) => (
|
||||||
</Group>
|
</Group>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default UIError;
|
export default UIError;
|
||||||
|
|
Loading…
Reference in a new issue