handling new errors
This commit is contained in:
parent
81dcbbc5b4
commit
3e1c91f19d
5 changed files with 23 additions and 20 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, pushNotificationsService, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, txFormatService, uxLanguage, $state, glideraService, isMobile, addressbookService) {
|
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, bwcService, pushNotificationsService, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, txFormatService, uxLanguage, $state, glideraService, isMobile, addressbookService) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var SOFT_CONFIRMATION_LIMIT = 12;
|
var SOFT_CONFIRMATION_LIMIT = 12;
|
||||||
|
var errors = bwcService.getErrors();
|
||||||
self.isCordova = isCordova;
|
self.isCordova = isCordova;
|
||||||
self.isChromeApp = isChromeApp;
|
self.isChromeApp = isChromeApp;
|
||||||
self.isSafari = isMobile.Safari();
|
self.isSafari = isMobile.Safari();
|
||||||
|
|
@ -470,10 +471,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
// Debounce function avoids multiple popups
|
// Debounce function avoids multiple popups
|
||||||
var _handleError = function(err) {
|
var _handleError = function(err) {
|
||||||
$log.warn('Client ERROR: ', err);
|
$log.warn('Client ERROR: ', err);
|
||||||
if (err.code === 'NOT_AUTHORIZED') {
|
if (err instanceof errors.NOT_AUTHORIZED) {
|
||||||
self.notAuthorized = true;
|
self.notAuthorized = true;
|
||||||
go.walletHome();
|
go.walletHome();
|
||||||
} else if (err.code === 'NOT_FOUND') {
|
} else if (err instanceof errors.NOT_FOUND) {
|
||||||
self.showErrorPopup(gettext('Could not access Wallet Service: Not found'));
|
self.showErrorPopup(gettext('Could not access Wallet Service: Not found'));
|
||||||
} else {
|
} else {
|
||||||
var msg = ""
|
var msg = ""
|
||||||
|
|
|
||||||
|
|
@ -286,8 +286,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
$rootScope.$on(eventName, function() {
|
$rootScope.$on(eventName, function() {
|
||||||
fc.getTx($scope.tx.id, function(err, tx) {
|
fc.getTx($scope.tx.id, function(err, tx) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
if (err.message && err.message == 'TX_NOT_FOUND' &&
|
||||||
if (err.code && err.code == 'TX_NOT_FOUND' &&
|
|
||||||
(eventName == 'transactionProposalRemoved' || eventName == 'TxProposalRemoved')) {
|
(eventName == 'transactionProposalRemoved' || eventName == 'TxProposalRemoved')) {
|
||||||
$scope.tx.removed = true;
|
$scope.tx.removed = true;
|
||||||
$scope.tx.canBeRemoved = false;
|
$scope.tx.canBeRemoved = false;
|
||||||
|
|
@ -1100,15 +1099,15 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
$scope.settings = walletSettings;
|
$scope.settings = walletSettings;
|
||||||
$scope.color = fc.backgroundColor;
|
$scope.color = fc.backgroundColor;
|
||||||
$scope.copayerId = fc.credentials.copayerId;
|
$scope.copayerId = fc.credentials.copayerId;
|
||||||
$scope.isShared = fc.credentials.n > 1;
|
$scope.isShared = fc.credentials.n > 1;
|
||||||
|
|
||||||
$scope.getAlternativeAmount = function() {
|
$scope.getAlternativeAmount = function() {
|
||||||
var satToBtc = 1 / 100000000;
|
var satToBtc = 1 / 100000000;
|
||||||
fc.getFiatRate({
|
fc.getFiatRate({
|
||||||
code : self.alternativeIsoCode,
|
code: self.alternativeIsoCode,
|
||||||
ts : btx.time * 1000
|
ts: btx.time * 1000
|
||||||
}, function(err, res) {
|
}, function(err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
$log.debug('Could not get historic rate');
|
$log.debug('Could not get historic rate');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,8 @@ angular.module('copayApp.services')
|
||||||
.factory('addressService', function(storageService, profileService, $log, $timeout, lodash, bwsError, gettextCatalog) {
|
.factory('addressService', function(storageService, profileService, $log, $timeout, lodash, bwsError, gettextCatalog) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
root.expireAddress = function(walletId, cb) {
|
||||||
root.expireAddress = function(walletId,cb) {
|
$log.debug('Cleaning Address ' + walletId);
|
||||||
$log.debug('Cleaning Address ' + walletId );
|
|
||||||
storageService.clearLastAddress(walletId, function(err) {
|
storageService.clearLastAddress(walletId, function(err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
});
|
});
|
||||||
|
|
@ -34,10 +33,13 @@ angular.module('copayApp.services')
|
||||||
return $timeout(function() {
|
return $timeout(function() {
|
||||||
root._createAddress(walletId, cb);
|
root._createAddress(walletId, cb);
|
||||||
}, 5000);
|
}, 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);
|
$log.warn(err.message);
|
||||||
prefix = null;
|
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);
|
if (err) return cb(err);
|
||||||
return cb(null, addr[0].address);
|
return cb(null, addr[0].address);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
.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 root = {};
|
||||||
|
var errors = bwcService.getErrors();
|
||||||
|
|
||||||
var FOREGROUND_UPDATE_PERIOD = 5;
|
var FOREGROUND_UPDATE_PERIOD = 5;
|
||||||
var BACKGROUND_UPDATE_PERIOD = 30;
|
var BACKGROUND_UPDATE_PERIOD = 30;
|
||||||
|
|
@ -284,8 +285,8 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
// check if exist
|
// check if exist
|
||||||
if (lodash.find(root.profile.credentials, {
|
if (lodash.find(root.profile.credentials, {
|
||||||
'walletId': walletData.walletId
|
'walletId': walletData.walletId
|
||||||
})) {
|
})) {
|
||||||
return cb(gettext('Cannot join the same wallet more that once'));
|
return cb(gettext('Cannot join the same wallet more that once'));
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
|
@ -509,8 +510,8 @@ angular.module('copayApp.services')
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
||||||
// in HW wallets, req key is always the same. They can't addAccess.
|
// in HW wallets, req key is always the same. They can't addAccess.
|
||||||
if (err.code == 'NOT_AUTHORIZED')
|
if (err instanceof errors.NOT_AUTHORIZED)
|
||||||
err.code = 'WALLET_DOES_NOT_EXIST';
|
err.name = 'WALLET_DOES_NOT_EXIST';
|
||||||
|
|
||||||
return bwsError.cb(err, gettext('Could not import'), cb);
|
return bwsError.cb(err, gettext('Could not import'), cb);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ angular.module('copayApp.services')
|
||||||
opts.type = isMobile.iOS() ? "ios" : isMobile.Android() ? "android" : null;
|
opts.type = isMobile.iOS() ? "ios" : isMobile.Android() ? "android" : null;
|
||||||
opts.token = token;
|
opts.token = token;
|
||||||
root.subscribe(opts, walletClient, function(err, response) {
|
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));
|
else $log.debug('Subscribed to push notifications service: ' + JSON.stringify(response));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue