The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/packages/grafana-ui/src/components/ErrorBoundary/ErrorWithStack.tsx

35 lines
735 B

import { css } from '@emotion/css';
import React from 'react';
import { useStyles2 } from '../../themes';
import { ErrorBoundaryApi } from './ErrorBoundary';
export interface Props extends ErrorBoundaryApi {
title: string;
}
export const ErrorWithStack = ({ error, errorInfo, title }: Props) => {
const style = useStyles2(getStyles);
return (
<div className={style}>
<h2>{title}</h2>
<details style={{ whiteSpace: 'pre-wrap' }}>
{error && error.toString()}
<br />
{errorInfo && errorInfo.componentStack}
</details>
</div>
);
};
ErrorWithStack.displayName = 'ErrorWithStack';
const getStyles = () => {
return css({
width: '500px',
margin: '64px auto',
});
};