@@ -89,8 +89,11 @@ define(function(require) {
8989 } ) ;
9090 }
9191 // fetch all collections
92- fetchEditorData ( courseData , function ( ) {
92+ fetchEditorData ( courseData , function ( error ) {
9393 if ( _ . isFunction ( callback ) ) callback ( ) ;
94+ if ( error ) {
95+ Origin . trigger ( 'editor:failedToLoad' ) ;
96+ }
9497 loadingCourseData = false ;
9598 Origin . trigger ( 'editor:dataLoaded' ) ;
9699 } ) ;
@@ -109,9 +112,15 @@ define(function(require) {
109112 if ( preloader . hasLoadedData ( ) ) {
110113 Origin . off ( 'editor:dataPreloaded' , done ) ;
111114 Origin . off ( 'editor:dataLoaded' , done ) ;
115+ Origin . off ( 'editor:failedToLoad' , removeEvents ) ;
112116 callback . apply ( this ) ;
113117 }
114- }
118+ } ;
119+ var removeEvents = function ( ) {
120+ Origin . off ( 'editor:dataPreloaded' , done ) ;
121+ Origin . off ( 'editor:dataLoaded' , done ) ;
122+ Origin . off ( 'editor:failedToLoad' , removeEvents ) ;
123+ } ;
115124 // in case we've already loaded
116125 done ( ) ;
117126
@@ -121,6 +130,7 @@ define(function(require) {
121130 if ( ! preloader . hasLoadedCourseData ( ) ) {
122131 Origin . on ( 'editor:dataLoaded' , done ) ;
123132 }
133+ Origin . on ( 'editor:failedToLoad' , removeEvents ) ;
124134 } ,
125135 /**
126136 * Uses the below checks to test loading status
@@ -176,7 +186,10 @@ define(function(require) {
176186 data [ collection . _type ] = true ;
177187 if ( callback && isAllDataLoaded ( data ) ) callback . apply ( this ) ;
178188 } ,
179- error : onFetchError
189+ error : function ( error ) {
190+ onFetchError ( ) ;
191+ callback ( error ) ;
192+ }
180193 } ) ;
181194 }
182195 }
@@ -216,6 +229,7 @@ define(function(require) {
216229 type : 'error' ,
217230 text : Origin . l10n . t ( 'app.errorgeneric' )
218231 } ) ;
232+ Origin . router . navigateTo ( 'dashboard' ) ;
219233 }
220234
221235 /**
0 commit comments