Skip to content

Commit

Permalink
Fix unhandled rejections not shown as errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ulilicht committed Jan 3, 2021
1 parent 8e5d109 commit 30e7510
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/react/ErrorBoundary/ErrorBoundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ErrorBoundary extends React.Component {
}

componentDidMount() {

const onErrorHandler = (errorEvent) => {
if (errorEvent.error.message.startsWith('EROFS: read-only file system, open \'/app.')) {
// this occurs within node-raumkernel if the app has no permissions to write to the filesystem.
Expand All @@ -27,7 +26,16 @@ class ErrorBoundary extends React.Component {
});
}

const onUnhandledRejectionHandler = (promiseRejectionEvent) => {
this.setState({
hasError: true,
error: promiseRejectionEvent.reason.message,
errorInfo: promiseRejectionEvent.reason.stack
});
}

window.addEventListener('error', onErrorHandler.bind(this));
window.addEventListener('unhandledrejection', onUnhandledRejectionHandler.bind(this));
}

componentDidCatch(error, errorInfo) {
Expand Down

0 comments on commit 30e7510

Please sign in to comment.