Instead of dying on page load when the offline DB fails to connect (e.g.
due to a duplicate key), log the error and allow the startup sequence to
complete.
Signed-off-by: Bill Erickson <berickxx@gmail.com>
egLovefield = $injector.get('egLovefield');
}
//console.debug('About to cache a list of ' + class_ + ' objects...');
- egLovefield.isCacheGood(class_).then(function(good) {
- if (!good) egLovefield.setListInOfflineCache(class_, blob.list);
- });
+ egLovefield.isCacheGood(class_).then(
+ function(good) {
+ if (!good) egLovefield.setListInOfflineCache(class_, blob.list);
+ },
+ function() {
+ console.error('offline DB needs to be reset');
+ }
+ );
}
angular.forEach(list, function(item) {blob.map[item[pkey]()] = item});
// a connection will never succeed.
service.cannotConnect = true;
console.error('Cannot connect to offline DB: ' + err);
+ deferred.reject();
}
);
} catch (e) {
// attempt is already in progress; this can happen with PhantomJS
console.error('Cannot connect to offline DB: ' + e);
service.cannotConnect = true;
+ deferred.reject();
}
service.connectPromise = deferred.promise;
if (here) service.cachedSettings[key] = settings[key];
});
- return egLovefield.setSettingsCache(settings).then(function() {
- // resolve with cached settings if 'here', since 'settings'
- // will only contain settings we had to retrieve
- deferred.resolve(here ? service.cachedSettings : settings);
- });
+ return egLovefield.setSettingsCache(settings).then(
+ function() {
+ // resolve with cached settings if 'here', since 'settings'
+ // will only contain settings we had to retrieve
+ deferred.resolve(here ? service.cachedSettings : settings);
+ },
+ function() {
+ console.error('offline db is not OK. ignoring');
+ deferred.resolve(here ? service.cachedSettings : settings);
+ }
+ );
});
return deferred.promise;
}