2023-12-07 16:33:37 +00:00
|
|
|
import { Alert } from "react-bootstrap";
|
2023-12-07 22:42:19 +00:00
|
|
|
import { ErrorWithLabel } from "../rqbit-web";
|
2023-12-07 16:33:37 +00:00
|
|
|
|
|
|
|
|
export const ErrorComponent = (props: {
|
2023-12-07 22:42:19 +00:00
|
|
|
error: ErrorWithLabel | null;
|
2023-12-07 16:33:37 +00:00
|
|
|
remove?: () => void;
|
|
|
|
|
}) => {
|
|
|
|
|
let { error, remove } = props;
|
|
|
|
|
|
|
|
|
|
if (error == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Alert variant="danger" onClose={remove} dismissible={remove != null}>
|
|
|
|
|
<Alert.Heading>{error.text}</Alert.Heading>
|
|
|
|
|
{error.details?.statusText && (
|
|
|
|
|
<p>
|
|
|
|
|
<strong>{error.details?.statusText}</strong>
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
<pre>{error.details?.text}</pre>
|
|
|
|
|
</Alert>
|
|
|
|
|
);
|
|
|
|
|
};
|