Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/components/error.tsx
5713 views
1
import { Alert } from "antd";
2
import { CSSProperties } from "react";
3
import StaticMarkdown from "@cocalc/frontend/editors/slate/static-markdown";
4
5
interface Props {
6
error: any;
7
setError?: (error: any) => void;
8
style?: CSSProperties;
9
message?;
10
banner?;
11
}
12
export default function ShowError({
13
message = "Error",
14
error,
15
setError,
16
style,
17
banner,
18
}: Props) {
19
if (!error) return null;
20
21
const err = `${error}`.replace(/^Error:/, "").trim();
22
return (
23
<Alert
24
banner={banner}
25
style={style}
26
showIcon
27
message={message}
28
type="error"
29
description={
30
<div style={{ maxHeight: "150px", overflow: "auto", textWrap: "wrap" }}>
31
<StaticMarkdown value={err} />
32
</div>
33
}
34
onClose={() => setError?.("")}
35
closable={setError != null}
36
/>
37
);
38
}
39
40