Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/components/error.tsx
1503 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
const err = `${error}`.replace(/^Error:/, "").trim();
21
return (
22
<Alert
23
banner={banner}
24
style={style}
25
showIcon
26
message={message}
27
type="error"
28
description={
29
<div style={{ maxHeight: "150px", overflow: "auto", textWrap: "wrap" }}>
30
<StaticMarkdown value={err} />
31
</div>
32
}
33
onClose={() => setError?.("")}
34
closable={setError != null}
35
/>
36
);
37
}
38
39