CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/components/error.tsx
Views: 687
1
import { Alert } from "antd";
2
import { CSSProperties } from "react";
3
4
interface Props {
5
error: any;
6
setError?: (error: any) => void;
7
style?: CSSProperties;
8
message?;
9
}
10
export default function ShowError({
11
message = "Error",
12
error,
13
setError,
14
style,
15
}: Props) {
16
if (!error) return null;
17
const err = `${error}`.replace(/^Error:/, "").trim();
18
return (
19
<Alert
20
style={style}
21
showIcon
22
message={message}
23
type="error"
24
description={
25
<div style={{ maxHeight: "150px", overflow: "auto", textWrap: "wrap" }}>
26
{err}
27
</div>
28
}
29
onClose={() => setError?.("")}
30
closable={setError != null}
31
/>
32
);
33
}
34
35