Skip to content
This repository was archived by the owner on May 19, 2020. It is now read-only.

Commit 9c65914

Browse files
author
Marco Segreto
authored
Merge pull request #1031 from 18F/ms-add_fetch_error_handling
Add more import fetch error handling
2 parents 7782e22 + 7bd13c8 commit 9c65914

4 files changed

Lines changed: 36 additions & 9 deletions

File tree

static_src/actions/org_actions.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import AppDispatcher from '../dispatcher.js';
88
import cfApi from '../util/cf_api.js';
9+
import errorActions from './error_actions.js';
910
import { orgActionTypes } from '../constants';
1011
import spaceActions from './space_actions';
1112

@@ -26,7 +27,14 @@ const orgActions = {
2627
orgGuid
2728
});
2829

29-
return cfApi.fetchOrg(orgGuid).then(orgActions.receivedOrg);
30+
return cfApi.fetchOrg(orgGuid)
31+
.then(orgActions.receivedOrg)
32+
.catch((err) =>
33+
errorActions.importantDataFetchError(
34+
err,
35+
'organization data may be incomplete'
36+
)
37+
);
3038
},
3139

3240
fetchAll() {
@@ -43,7 +51,13 @@ const orgActions = {
4351
)
4452
)
4553
)
46-
.then(orgActions.receivedOrgs);
54+
.then(orgActions.receivedOrgs)
55+
.catch((err) =>
56+
errorActions.importantDataFetchError(
57+
err,
58+
'unable to fetch organizations'
59+
)
60+
);
4761
},
4862

4963
receivedOrg(org) {

static_src/actions/service_actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const serviceActions = {
2828
)
2929
.then(serviceActions.receivedServices)
3030
.catch((err) =>
31-
errorActions.importantDataFetchError(err, 'unable to fetch services')
31+
errorActions.importantDataFetchError(err, 'unable to fetch marketplace')
3232
);
3333
},
3434

static_src/actions/space_actions.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import AppDispatcher from '../dispatcher.js';
88
import cfApi from '../util/cf_api';
9+
import errorActions from './error_actions.js';
910
import { spaceActionTypes } from '../constants.js';
1011
import SpaceStore from '../stores/space_store';
1112

@@ -16,17 +17,23 @@ export default {
1617
spaceGuid
1718
});
1819

19-
// TODO error action should also be specified here
20-
return cfApi.fetchSpace(spaceGuid).then(this.receivedSpace);
20+
return cfApi.fetchSpace(spaceGuid)
21+
.then(this.receivedSpace)
22+
.catch((err) =>
23+
errorActions.importantDataFetchError(err, 'unable to fetch space')
24+
);
2125
},
2226

2327
fetchAll() {
2428
AppDispatcher.handleViewAction({
2529
type: spaceActionTypes.SPACES_FETCH
2630
});
2731

28-
// TODO error action should also be specified here
29-
return cfApi.fetchSpaces().then(this.receivedSpaces);
32+
return cfApi.fetchSpaces()
33+
.then(this.receivedSpaces)
34+
.catch((err) =>
35+
errorActions.importantDataFetchError(err, 'space data may be incomplete')
36+
);
3037
},
3138

3239
fetchAllForOrg(orgGuid) {
@@ -35,10 +42,12 @@ export default {
3542
orgGuid
3643
});
3744

38-
// TODO error action should also be specified here
3945
return Promise.all(SpaceStore.getAll()
4046
.filter(space => space.organization_guid === orgGuid)
4147
.map(space => this.fetch(space.guid))
48+
)
49+
.catch((err) =>
50+
errorActions.importantDataFetchError(err, 'space data may be incomplete')
4251
);
4352
},
4453

static_src/components/app_container.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ function appReady(app) {
3131
}
3232

3333
function stateSetter() {
34+
let route;
3435
const currentAppGuid = AppStore.currentAppGuid;
3536
const app = AppStore.get(currentAppGuid);
3637
const space = SpaceStore.get(SpaceStore.currentSpaceGuid);
3738
const org = OrgStore.get(OrgStore.currentOrgGuid);
39+
40+
if (app) {
3841
// This depends on DomainStore
39-
const route = RouteStore.getRouteURLForApp(app);
42+
route = RouteStore.getRouteURLForApp(app);
43+
}
4044

4145
const quotaGuid = (space && space.space_quota_definition_guid) ||
4246
(org && org.quota_definition_guid) || null;

0 commit comments

Comments
 (0)