// @flow import { Lbryio } from 'lbryinc'; import * as React from 'react'; import Yrbl from 'component/yrbl'; import Button from 'component/button'; type Props = { children: React.Node, }; type State = { hasError: boolean, }; export default class ErrorBoundary extends React.Component { constructor() { super(); this.state = { hasError: false }; } static getDerivedStateFromError() { return { hasError: true }; } componentDidCatch(error: { stack: string }) { declare var app: { env: string }; const errorMessage = ` ${window.location.pathname + window.location.search}\n ${error.stack} `; if (app.env === 'production') { Lbryio.call('event', 'desktop_error', { error_message: errorMessage }); } } render() { if (this.state.hasError) { return (

{__("There was an error. It's been reported and will be fixed")}. {__('Try')}{' '}

} /> ); } return this.props.children; } }