Merge pull request #1975 from isocolsky/error_storing

Error storing
This commit is contained in:
Matias Alejo Garcia 2014-12-04 17:51:03 -03:00
commit a02737bcfc
2 changed files with 14 additions and 5 deletions

View file

@ -237,6 +237,8 @@ Identity.prototype.retrieveWalletFromStorage = function(walletId, opts, cb) {
* @param {Function} cb
*/
Identity.prototype.storeWallet = function(wallet, cb) {
var self = this;
preconditions.checkArgument(wallet && _.isObject(wallet));
wallet.setVersion(this.version);
@ -246,8 +248,14 @@ Identity.prototype.storeWallet = function(wallet, cb) {
this.storage.setItem(key, val, function(err) {
if (err) {
log.error('Wallet:' + wallet.getName() + ' couldnt be stored:', err);
log.error('Wallet:' + wallet.getName() + ' could not be stored:', err);
log.error('Wallet:' + wallet.getName() + ' Size:', JSON.stringify(wallet.sizes()));
if (err.match('OVERQUOTA')) {
self.emitAndKeepAlive('walletStorageError', wallet.getId(), 'Storage limits on remote server exceeded');
} else {
self.emitAndKeepAlive('walletStorageError', wallet.getId(), err);
}
}
if (cb)
return cb(err);
@ -576,12 +584,9 @@ Identity.prototype.createWallet = function(opts, cb) {
var self = this;
var w = new walletClass(opts);
console.log(_.keys(self.wallets));
console.log(w.getId());
if (_.contains(_.keys(self.wallets), w.getId())) {
if (self.wallets[w.getId()]) {
return cb('walletAlreadyExists');
}
self.wallets[w.getId()] = w;
self.updateFocusedTimestamp(w.getId());
self.bindWallet(w);

View file

@ -307,6 +307,10 @@ angular.module('copayApp.services')
// do nothing. this is handled 'on sync' on controller.
});
iden.on('walletStorageError', function (wid, message) {
notification.error('Error storing wallet', message);
});
iden.on('closed', function() {
delete $rootScope['wallet'];
delete $rootScope['iden'];