I want to handle the gracefully in the client side when one or more libraries failed to load for some reason, currently the promises are getting fulfilled when this happens.

I tried timeout to see if the libraries work but this doesn't help me in all situations.

 var loadPromises = [];
    loadPromises.push(gapi.client.load('myApp', 'v1', null, apiRoot));
    loadPromises.push(gapi.client.load(apiRoot + '/discovery/v1/apis/myApp/v1/rest'));
    loadPromises.push(gapi.load('client:auth2'));


    loadPromises.push(gapi.client.load('https://www.googleapis.com/discovery/v1/apis/drive/v3/rest'));

            $q.all(loadPromises).then(function() {
                this.$q.defer().resolve(true);
            }).catch(function(err){
              console.error(err);
              this.$q.defer().reject(err);
            });

No error in the console, the UI doesn't show because of the libraries failed to load correctly.

0 Answers