// SPDX-FileCopyrightText: © 2017 EteSync Authors // SPDX-License-Identifier: AGPL-3.0-only import * as React from "react"; import { IntegrityError } from "etebase"; import PrettyError from "../widgets/PrettyError"; interface PropsType { children: React.ReactNode | React.ReactNode[]; } class ErrorBoundary extends React.Component { public state: { error?: Error; }; constructor(props: PropsType) { super(props); this.state = { }; } public componentDidCatch(error: Error, _info: any) { this.setState({ error }); } public render() { const { error } = this.state; if (error) { if (error instanceof IntegrityError) { return (

Integrity Error

Please log out from the menu, refresh the page and try again, and if the problem persists, contact support.

              {error.message}
            
); } } if (error) { return (

Something went wrong!

); } return this.props.children; } } export default ErrorBoundary;