66
77import AppDispatcher from '../dispatcher.js' ;
88import cfApi from '../util/cf_api' ;
9+ import errorActions from './error_actions.js' ;
910import { spaceActionTypes } from '../constants.js' ;
1011import 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
0 commit comments