From bee64590612cec775766319d961e5b5a2cd31191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Tue, 14 Feb 2017 16:34:48 +0000 Subject: [PATCH 1/5] Improve exception handling in mobile main --- src/main.mobile.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.mobile.js b/src/main.mobile.js index 5e3b558..e1064e2 100644 --- a/src/main.mobile.js +++ b/src/main.mobile.js @@ -26,15 +26,15 @@ class MeasurementWrapper extends React.Component { } render () { - if (!this.state.measurement) { + if (this.state.error !== null) { return
-

Loading

+

Error in loading the measurement

+
{this.state.error.toString()}
} - if (this.state.error !== null) { - return
-

Error in loading measurement

-
{this.state.error.toString()}
+ if (!this.state.measurement) { + return
+

Loading

} return
From 5a72dea316839ead7e03c27f952739c7707571c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Wed, 15 Feb 2017 13:50:17 +0000 Subject: [PATCH 2/5] Handle also errors in rendering the views --- src/main.mobile.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/main.mobile.js b/src/main.mobile.js index e1064e2..77c2c03 100644 --- a/src/main.mobile.js +++ b/src/main.mobile.js @@ -6,6 +6,22 @@ import './styles/core.mobile.scss' // ======================================================== // Mobile specific wrapping // ======================================================== + +const ErrorMessage = ({ + error +}) => { + return ( +
+

Error in loading the measurement

+
{error.toString()}
+
+ ) +} + +ErrorMessage.propTypes = { + error: React.PropTypes.object +} + class MeasurementWrapper extends React.Component { constructor (props) { super(props) @@ -27,10 +43,7 @@ class MeasurementWrapper extends React.Component { render () { if (this.state.error !== null) { - return
-

Error in loading the measurement

-
{this.state.error.toString()}
-
+ return } if (!this.state.measurement) { return
@@ -49,10 +62,17 @@ class MeasurementWrapper extends React.Component { const MOUNT_NODE = document.getElementById('root') let render = () => { - ReactDOM.render( - , - MOUNT_NODE - ) + try { + ReactDOM.render( + , + MOUNT_NODE + ) + } catch (error) { + ReactDOM.render( + , + MOUNT_NODE + ) + } } // ======================================================== From 6f0fb7e50dbc7c088a82e5eb74931801502eca66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Wed, 15 Feb 2017 14:08:14 +0000 Subject: [PATCH 3/5] Handle exceptions in a cleaner way --- src/main.mobile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.mobile.js b/src/main.mobile.js index 77c2c03..aa8142c 100644 --- a/src/main.mobile.js +++ b/src/main.mobile.js @@ -12,8 +12,9 @@ const ErrorMessage = ({ }) => { return (
+