Skip to content

Commit 67eb02c

Browse files
authored
Merge pull request #1283 from jvwong/iss1210_error-handling-enrichment
Error handling: Enrichment
2 parents b87c2bf + 70a9e14 commit 67eb02c

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/client/features/enrichment/index.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@ const classNames = require('classnames');
66
const queryString = require('query-string');
77

88
const EnrichmentToolbar = require('./enrichment-toolbar');
9-
const { EmptyNetwork, PcLogoLink, CytoscapeNetwork, Popover } = require('../../common/components/');
9+
const { PcLogoLink, CytoscapeNetwork, Popover } = require('../../common/components/');
1010

1111
const CytoscapeService = require('../../common/cy/');
1212
const { ServerAPI } = require('../../services');
1313

1414
const { enrichmentLayout, enrichmentStylesheet, bindEvents } = require('./cy');
15+
const { TimeoutError } = require('../../../util');
16+
const { ErrorMessage } = require('../../common/components/error-message');
17+
1518
class Enrichment extends React.Component {
1619
constructor(props){
1720
super(props);
1821

1922
this.state = {
2023
cySrv: new CytoscapeService({ style: enrichmentStylesheet, onMount: bindEvents }),
2124
sources: _.uniq(queryString.parse(props.location.search).source.split(',')),
22-
errored: false,
25+
error: null,
2326
loading: true,
2427
networkEmpty: false
2528
};
@@ -57,7 +60,7 @@ class Enrichment extends React.Component {
5760
});
5861
} catch( e ){
5962
this.setState({
60-
errored: true,
63+
error: e,
6164
loading: false
6265
});
6366
}
@@ -67,9 +70,18 @@ class Enrichment extends React.Component {
6770
}
6871

6972
render(){
70-
let { loading, cySrv, networkEmpty, sources } = this.state;
73+
let { loading, cySrv, networkEmpty, sources, error } = this.state;
7174
let titleContent = [];
7275

76+
let errorMessage;
77+
if( networkEmpty ) {
78+
errorMessage = h(ErrorMessage, { title: 'No results to display.', body: 'Try different genes in your search.' , footer: null, logo: true } );
79+
} else if( error instanceof TimeoutError ) {
80+
errorMessage = h( ErrorMessage, { title: 'This is taking longer that we expected', body: 'Try again later.', logo: true } );
81+
} else if( error ) {
82+
errorMessage = h( ErrorMessage, { logo: true } );
83+
}
84+
7385
if( sources.length === 1 ){
7486
titleContent.push(h('span', `Pathways enriched for ${sources[0]}`));
7587
}
@@ -95,17 +107,15 @@ class Enrichment extends React.Component {
95107
h(EnrichmentToolbar, { cySrv, sources: this.state.sources, controller: this })
96108
]);
97109

98-
return h('div.enrichment', [
99-
110+
return !errorMessage ? [ h('div.enrichment', [
100111
h(Loader, { loaded: !loading, options: { left: '50%', color: '#16a085' }}, [
101112
appBar
102113
]),
103-
networkEmpty ? h(EmptyNetwork, { msg: 'No results to display', showPcLink: false} ) : null,
104114
h(CytoscapeNetwork, {
105115
cySrv,
106116
className: classNames({'network-loading': loading})
107117
})
108-
]);
118+
]) ]: [errorMessage];
109119
}
110120
}
111121

0 commit comments

Comments
 (0)