More detailed error boundary for Document

This commit is contained in:
Jori Lallo
2017-12-03 19:18:22 -08:00
parent 4283f48f00
commit 060066ceee
3 changed files with 83 additions and 71 deletions

View File

@ -8,7 +8,7 @@ type Props = {
const Container = styled.div`
width: 100%;
margin: 60px;
padding: 60px;
`;
const Content = styled.div`

View File

@ -9,6 +9,14 @@ import PageTitle from 'components/PageTitle';
class ErrorBoundary extends Component {
@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) {
this.error = true;
@ -27,9 +35,10 @@ class ErrorBoundary extends Component {
return (
<CenteredContent>
<PageTitle title="Something went wrong" />
<h1>Something went wrong</h1>
<h1>🛸 Something unexpected happened</h1>
<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>.
</p>
</CenteredContent>

View File

@ -33,6 +33,7 @@ import CenteredContent from 'components/CenteredContent';
import PageTitle from 'components/PageTitle';
import NewDocumentIcon from 'components/Icon/NewDocumentIcon';
import Actions, { Action, Separator } from 'components/Actions';
import ErrorBoundary from 'components/ErrorBoundary';
import Search from 'scenes/Search';
const DISCARD_CHANGES = `
@ -216,6 +217,7 @@ class DocumentScene extends Component {
return (
<Container column auto>
<ErrorBoundary location={this.props.location}>
{isMoving && document && <DocumentMove document={document} />}
{titleText && <PageTitle title={titleText} />}
{(this.isLoading || this.isSaving) && <LoadingIndicator />}
@ -285,6 +287,7 @@ class DocumentScene extends Component {
</Actions>
</Flex>
)}
</ErrorBoundary>
</Container>
);
}