import { Button, Col, Collapse, Result, Row, Space } from "antd"; import React from "react"; import * as Sentry from "@sentry/electron/renderer"; class ErrorBoundary extends React.Component { constructor() { super(); this.state = { hasErrored: false, error: null, info: null, }; } static getDerivedStateFromError(error) { console.log("ErrorBoundary -> getDerivedStateFromError -> error", error); Sentry.captureException(error); return { hasErrored: true, error: error }; } componentDidCatch(error, info) { console.log("Exception Caught by Error Boundary.", error, info); Sentry.captureException(error); this.setState({ ...this.state, error, info }); } render() { if (this.state.hasErrored === true) { const errorItems = [ { key: "error-details", label: "Error Details", children: ( <>
{this.state.error.message}
{this.state.error.stack}
) } ]; return (
} />
); } else { return this.props.children; } } } export default ErrorBoundary;