From 364706b7084c2a989ee4329fbb1696d5080260e7 Mon Sep 17 00:00:00 2001 From: notnull Date: Wed, 26 Jun 2019 10:50:39 -0400 Subject: [PATCH] handle network error / show more verbose error message --- src/App.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index 845e643..b477422 100644 --- a/src/App.js +++ b/src/App.js @@ -112,7 +112,22 @@ class App extends React.Component { return
Loading...
} renderError() { - return
Something went wrong. Please try again.
+ if (this.state.error.message === 'Network Error') { + alert(`Failed to reach backend at\n${this.state.error.config.url}.`) + } else { + return ( +
+ There was an error: {this.state.error.message} + +
+ ) + } } renderProfile() { return ( @@ -200,6 +215,8 @@ class App extends React.Component { const renderComponent = () => this.state.loading ? this.renderLoading() + : this.state.error + ? this.renderError() : this.state.component === 'tasks' ? this.renderTasks(filtered, completed) : this.state.component === 'task'