handling new errors

This commit is contained in:
Javier 2016-01-22 18:16:50 -03:00
commit 3e1c91f19d
5 changed files with 23 additions and 20 deletions

View file

@ -4,9 +4,8 @@ angular.module('copayApp.services')
.factory('addressService', function(storageService, profileService, $log, $timeout, lodash, bwsError, gettextCatalog) {
var root = {};
root.expireAddress = function(walletId,cb) {
$log.debug('Cleaning Address ' + walletId );
root.expireAddress = function(walletId, cb) {
$log.debug('Cleaning Address ' + walletId);
storageService.clearLastAddress(walletId, function(err) {
return cb(err);
});
@ -34,10 +33,13 @@ angular.module('copayApp.services')
return $timeout(function() {
root._createAddress(walletId, cb);
}, 5000);
} else if (err.code && err.code == 'MAIN_ADDRESS_GAP_REACHED') {
} else if (err.message && err.message == 'MAIN_ADDRESS_GAP_REACHED') {
$log.warn(err.message);
prefix = null;
client.getMainAddresses({reverse: true, limit : 1}, function(err, addr) {
client.getMainAddresses({
reverse: true,
limit: 1
}, function(err, addr) {
if (err) return cb(err);
return cb(null, addr[0].address);
});

View file

@ -3,6 +3,7 @@ angular.module('copayApp.services')
.factory('profileService', function profileServiceFactory($rootScope, $location, $timeout, $filter, $log, lodash, storageService, bwcService, configService, notificationService, pushNotificationsService, isChromeApp, isCordova, gettext, gettextCatalog, nodeWebkit, bwsError, uxLanguage, bitcore) {
var root = {};
var errors = bwcService.getErrors();
var FOREGROUND_UPDATE_PERIOD = 5;
var BACKGROUND_UPDATE_PERIOD = 30;
@ -284,8 +285,8 @@ angular.module('copayApp.services')
// check if exist
if (lodash.find(root.profile.credentials, {
'walletId': walletData.walletId
})) {
'walletId': walletData.walletId
})) {
return cb(gettext('Cannot join the same wallet more that once'));
}
} catch (ex) {
@ -509,8 +510,8 @@ angular.module('copayApp.services')
if (err) {
// in HW wallets, req key is always the same. They can't addAccess.
if (err.code == 'NOT_AUTHORIZED')
err.code = 'WALLET_DOES_NOT_EXIST';
if (err instanceof errors.NOT_AUTHORIZED)
err.name = 'WALLET_DOES_NOT_EXIST';
return bwsError.cb(err, gettext('Could not import'), cb);
}

View file

@ -48,7 +48,7 @@ angular.module('copayApp.services')
opts.type = isMobile.iOS() ? "ios" : isMobile.Android() ? "android" : null;
opts.token = token;
root.subscribe(opts, walletClient, function(err, response) {
if (err) $log.warn('Subscription error: ' + err.code);
if (err) $log.warn('Subscription error: ' + err.message);
else $log.debug('Subscribed to push notifications service: ' + JSON.stringify(response));
});
});