Currently we do not notify the user in an appropriate way. Sometimes we just log the error or call alert() - this is not user-friendly and not informative. I suggest that we build upon the error component that was introduced by @HmG248 a new more generic component that is called when one of the service calls fails. Here is an example:
ClassService.getClassesOfUser().then((data) => {
this.setState({
classes: [...data],
loading: false
});
}).catch((e) => {
console.error(e);
});
error : {
fired: false,
errorCode: 0,
errorMsg: ''
},
ClassService.getClassesOfUser().then((data) => {
this.setState({
classes: [...data],
loading: false
});
}).catch((e) => {
this.setState({error: {fired: true, errorCode: e.Code, errorMsg: e.Msg}});
});
<ErrorComponent
visible={this.state.error.fired}
error={this.state.error}
closeDialog={()=>{this.setState(
{error:
{
fired:false,
errorCode:0,
errorMsg:''
}
})
}}
/>