@@ -14,6 +14,26 @@ zsd.config(['$routeProvider', function($routeProvider){
1414 otherwise ( { redirectTo : '/by-file' } ) ;
1515} ] ) ;
1616
17+ zsd . config ( [ '$httpProvider' , function ( $httpProvider ) {
18+ $httpProvider . interceptors . push ( 'HTTPErrorInterceptor' ) ;
19+ } ] ) ;
20+
21+ zsd . factory ( 'HTTPErrorInterceptor' , [ '$q' , '$rootScope' , function ( $q , $rootScope ) {
22+ return {
23+ 'requestError' : function ( rejection ) {
24+ console . log ( "requestError" ) ;
25+ console . log ( rejection ) ;
26+ return $q . reject ( rejection ) ;
27+ } ,
28+ 'responseError' : function ( rejection ) {
29+ // 406 are handled in the controller (file size limit)
30+ if ( rejection . status !== 406 ) {
31+ $rootScope . $broadcast ( 'response-error' , rejection ) ;
32+ }
33+ return $q . reject ( rejection ) ;
34+ }
35+ } ;
36+ } ] ) ;
1737
1838zsd . factory ( 'Config' , [ "$http" , function ( $http ) {
1939 var config ;
@@ -191,20 +211,26 @@ zsd.directive('dirBrowser', ['Backend', function(Backend){
191211 } ;
192212} ] ) ;
193213
194- zsd . controller ( 'MainCtrl' , [ " $location" , " Config" , function ( $location , Config ) {
214+ zsd . controller ( 'MainCtrl' , [ ' $location' , '$rootScope' , ' Config' , function ( $location , $rootScope , Config ) {
195215 var self = this ;
196216
197217
218+
198219 Config . promise . then ( function ( ) {
199220 self . config = Config . config ( ) ;
200221 } ) ;
201222
223+ $rootScope . $on ( 'response-error' , function ( event , args ) {
224+ self . error = args . data ;
225+ } ) ;
202226
203227
204228 self . activeClassIfAt = function ( path ) {
205229 return { active : $location . path ( ) === path } ;
206230 } ;
207231
232+
233+
208234} ] ) ;
209235
210236
0 commit comments