diff options
| author | Haishan <[email protected]> | 2020-09-13 16:34:18 +0800 |
|---|---|---|
| committer | Haishan <[email protected]> | 2020-09-13 17:16:14 +0800 |
| commit | 15bc0f69a8367a57fa1bf263e615285349ad4ab9 (patch) | |
| tree | fbdd2a46303703822f7e7bc3462a70b4855fe4a1 /src/components/ErrorBoundary.js | |
| parent | a8f0d3d4b4928caebf61c75fa9191a170b471035 (diff) | |
feat: multi backends management
Diffstat (limited to 'src/components/ErrorBoundary.js')
| -rw-r--r-- | src/components/ErrorBoundary.js | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/src/components/ErrorBoundary.js b/src/components/ErrorBoundary.js index cc3898e..ff49e1e 100644 --- a/src/components/ErrorBoundary.js +++ b/src/components/ErrorBoundary.js @@ -1,13 +1,10 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +// import { getSentry } from '../misc/sentry'; import { deriveMessageFromError } from '../misc/errors'; -import { getSentry } from '../misc/sentry'; import ErrorBoundaryFallback from './ErrorBoundaryFallback'; -// XXX this is no Hook equivalents for componentDidCatch -// we have to use class for now - class ErrorBoundary extends Component { static propTypes = { children: PropTypes.node, @@ -15,44 +12,13 @@ class ErrorBoundary extends Component { state = { error: null }; - loadSentry = async () => { - if (this.sentry) return this.sentry; - const x = await getSentry(); - this.sentry = x; - return this.sentry; - }; - - // static getDerivedStateFromError(error) { - // return { error }; - // } - - componentDidMount() { - // this.loadSentry(); + static getDerivedStateFromError(error) { + return { error }; } - componentDidCatch(error, _info) { - this.setState({ error }); - // eslint-disable-next-line no-console - // console.log(error, errorInfo); - // this.setState({ error }); - // this.loadSentry().then(Sentry => { - // Sentry.withScope(scope => { - // Object.keys(errorInfo).forEach(key => { - // scope.setExtra(key, errorInfo[key]); - // }); - // Sentry.captureException(error); - // }); - // }); - } - - showReportDialog = () => { - this.loadSentry().then((Sentry) => Sentry.showReportDialog()); - }; - render() { if (this.state.error) { const { message, detail } = deriveMessageFromError(this.state.error); - //render fallback UI return <ErrorBoundaryFallback message={message} detail={detail} />; } else { return this.props.children; |
