Files
spark/src/DataStreamSuite/Bts.DataStreamWebApp.Client/src/ErrorView.jsx
T

43 lines
1.3 KiB
React

import React from 'react';
import { Box, Typography, Collapse } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import Alert from '@mui/material/Alert';
import AlertTitle from '@mui/material/AlertTitle';
const ErrorView = ({ error }) => {
const theme = useTheme();
const [open, setOpen] = React.useState(false);
if (!error) {
return null;
}
return (
<Box sx={{ margin: theme.spacing(2) }}>
<Alert severity="error" onClick={() => setOpen(!open)} sx={{ cursor: 'pointer' }}>
<AlertTitle>Error Code: {error.code}</AlertTitle>
{error.message}
</Alert>
<Collapse in={open}>
<Box
sx={{
backgroundColor: theme.palette.error.light,
color: theme.palette.error.contrastText,
padding: theme.spacing(2),
marginTop: theme.spacing(1),
borderRadius: theme.shape.borderRadius,
}}
>
<Typography variant="body1">{error.data.error_message}</Typography>
<Typography variant="subtitle1">Stack Trace:</Typography>
<Typography variant="body2" component="pre" sx={{ whiteSpace: 'pre-wrap' }}>
{error.data.stack_trace}
</Typography>
</Box>
</Collapse>
</Box>
);
};
export default ErrorView;