More detailed error boundary for Document
This commit is contained in:
@ -8,7 +8,7 @@ type Props = {
|
|||||||
|
|
||||||
const Container = styled.div`
|
const Container = styled.div`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 60px;
|
padding: 60px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Content = styled.div`
|
const Content = styled.div`
|
||||||
|
@ -9,6 +9,14 @@ import PageTitle from 'components/PageTitle';
|
|||||||
class ErrorBoundary extends Component {
|
class ErrorBoundary extends Component {
|
||||||
@observable error: boolean = false;
|
@observable error: boolean = false;
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps: Object) {
|
||||||
|
if (
|
||||||
|
(this.props.location || nextProps.location) &&
|
||||||
|
this.props.location.pathname !== nextProps.location.pathname
|
||||||
|
)
|
||||||
|
this.error = false;
|
||||||
|
}
|
||||||
|
|
||||||
componentDidCatch(error: Error, info: Object) {
|
componentDidCatch(error: Error, info: Object) {
|
||||||
this.error = true;
|
this.error = true;
|
||||||
|
|
||||||
@ -27,9 +35,10 @@ class ErrorBoundary extends Component {
|
|||||||
return (
|
return (
|
||||||
<CenteredContent>
|
<CenteredContent>
|
||||||
<PageTitle title="Something went wrong" />
|
<PageTitle title="Something went wrong" />
|
||||||
<h1>Something went wrong</h1>
|
<h1>🛸 Something unexpected happened</h1>
|
||||||
<p>
|
<p>
|
||||||
An unrecoverable error occurred. Please try{' '}
|
An unrecoverable error occurred{window.Bugsnag ||
|
||||||
|
(true && ' and our engineers have been notified')}. Please try{' '}
|
||||||
<a onClick={this.handleReload}>reloading</a>.
|
<a onClick={this.handleReload}>reloading</a>.
|
||||||
</p>
|
</p>
|
||||||
</CenteredContent>
|
</CenteredContent>
|
||||||
|
@ -33,6 +33,7 @@ import CenteredContent from 'components/CenteredContent';
|
|||||||
import PageTitle from 'components/PageTitle';
|
import PageTitle from 'components/PageTitle';
|
||||||
import NewDocumentIcon from 'components/Icon/NewDocumentIcon';
|
import NewDocumentIcon from 'components/Icon/NewDocumentIcon';
|
||||||
import Actions, { Action, Separator } from 'components/Actions';
|
import Actions, { Action, Separator } from 'components/Actions';
|
||||||
|
import ErrorBoundary from 'components/ErrorBoundary';
|
||||||
import Search from 'scenes/Search';
|
import Search from 'scenes/Search';
|
||||||
|
|
||||||
const DISCARD_CHANGES = `
|
const DISCARD_CHANGES = `
|
||||||
@ -216,6 +217,7 @@ class DocumentScene extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container column auto>
|
<Container column auto>
|
||||||
|
<ErrorBoundary location={this.props.location}>
|
||||||
{isMoving && document && <DocumentMove document={document} />}
|
{isMoving && document && <DocumentMove document={document} />}
|
||||||
{titleText && <PageTitle title={titleText} />}
|
{titleText && <PageTitle title={titleText} />}
|
||||||
{(this.isLoading || this.isSaving) && <LoadingIndicator />}
|
{(this.isLoading || this.isSaving) && <LoadingIndicator />}
|
||||||
@ -285,6 +287,7 @@ class DocumentScene extends Component {
|
|||||||
</Actions>
|
</Actions>
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
|
</ErrorBoundary>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user