commit 83e73c5579072e131e26b2e077aba62a8763cd1e parent a55d311492b82dc6db19f3100d0a1b0b214d8fb9 Author: Konstantin Tarkus <koistya@gmail.com> Date: Sun, 5 Feb 2017 22:21:25 +0300 Add error handler for errors that might happen after rendering (#1113) Diffstat:
| M | src/client.js | | | 11 | +++++++++++ |
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/client.js b/src/client.js @@ -176,6 +176,17 @@ async function onLocationChange(location) { history.listen(onLocationChange); onLocationChange(currentLocation); +// Handle errors that might happen after rendering +// Display the error in full-screen for development mode +if (process.env.NODE_ENV !== 'production') { + window.addEventListener('error', (e) => { + console.error(e.error); // eslint-disable-line no-console + + document.title = `Error: ${e.error.message}`; + ReactDOM.render(<ErrorReporter error={e.error} />, container); + }); +} + // Enable Hot Module Replacement (HMR) if (module.hot) { module.hot.accept('./routes', () => {