forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show disappointed elephant if web UI crashes (mastodon#10275)
* Do not crash the whole UI when loading an invalid column * Add error boundary component to catch Web UI crashes * Add stack trace on supported browsers * Add component stack info, pre-format everything for github * Make “Reload” a clickable link that calls window.location.reload() * Remove elephant friend from error boundary, make title stand out more * Simplify error boundary to only a graphic
- Loading branch information
1 parent
f79e432
commit f96d5aa
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import illustration from '../../images/elephant_ui_disappointed.svg'; | ||
|
||
export default class ErrorBoundary extends React.PureComponent { | ||
|
||
static propTypes = { | ||
children: PropTypes.node, | ||
}; | ||
|
||
state = { | ||
hasError: false, | ||
stackTrace: undefined, | ||
componentStack: undefined, | ||
} | ||
|
||
componentDidCatch(error, info) { | ||
this.setState({ | ||
hasError: true, | ||
stackTrace: error.stack, | ||
componentStack: info && info.componentStack, | ||
}); | ||
} | ||
|
||
render() { | ||
const { hasError } = this.state; | ||
|
||
if (!hasError) { | ||
return this.props.children; | ||
} | ||
|
||
return ( | ||
<div> | ||
<img src={illustration} alt='' /> | ||
</div> | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters