import { IconPatch } from "components/buttons/IconPatch"; import { Icons } from "components/Icon"; import { Link } from "components/text/Link"; import { Title } from "components/text/Title"; import { DISCORD_LINK, GITHUB_LINK } from "mw_constants"; import { Component } from "react"; interface ErrorBoundaryState { hasError: boolean; error?: { name: string; description: string; path: string; }; } export class ErrorBoundary extends Component< Record, ErrorBoundaryState > { constructor(props: { children: any }) { super(props); this.state = { hasError: false, }; } static getDerivedStateFromError() { return { hasError: true, }; } componentDidCatch(error: any, errorInfo: any) { console.error("Render error caught", error, errorInfo); if (error instanceof Error) { const realError: Error = error as Error; this.setState((s) => ({ ...s, hasError: true, error: { name: realError.name, description: realError.message, path: errorInfo.componentStack.split("\n")[1], }, })); } } render() { if (!this.state.hasError) return this.props.children; return (
Whoops, it broke

The app encountered an error and wasn't able to recover, please report it to the{" "} Discord server {" "} or on{" "} GitHub .

{this.state.error ? (

{this.state.error.name} - {this.state.error.description}

{this.state.error.path}

) : null}
); } }