better handling clientError

This commit is contained in:
Matias Alejo Garcia 2015-04-13 16:24:25 -03:00
parent 9efa2dfe24
commit 6186a70a50
2 changed files with 5 additions and 9 deletions

View File

@ -40,7 +40,7 @@
</div>
</div>
<div ng-show="index.updateError">
<div ng-show="index.updateError && !index.notAuthorized">
<div class="text-center text-warning m10t">
<i class="fi-alert"></i>
<span translate>

View File

@ -157,7 +157,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.setOngoingProcess('updatingTxHistory', false);
if (err) {
$log.debug('TxHistory ERROR:', err);
$scope.$emit('Local/ClientError', err);
self.handleError(err);
self.txHistoryError = true;
} else {
$log.debug('Wallet Transaction History:', txs);
@ -175,8 +175,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$scope.$emit('Local/NotAuthorized');
} else if (err.code === 'NOTFOUND') {
$scope.$emit('Local/BWSNotFound');
} else if (err.code === 'ETIMEDOUT') {
$scope.$emit('Local/BWSTimeOut');
} else {
$scope.$emit('Local/ClientError', err);
}
@ -400,6 +398,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$on(eventName, function(event) {
$log.debug('### Online event');
self.isOffline = false;
self.clientError = null;
self.updateAll();
self.updateTxHistory();
});
@ -426,17 +425,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$apply();
});
$rootScope.$on('Local/BWSTimeOut', function(event) {
self.clientError = 'Could not access to Bitcore Wallet Service: Timed out';
$rootScope.$apply();
});
$rootScope.$on('Local/ClientError', function(event, err) {
if (err.code && err.code === 'NOTAUTHORIZED') {
// Show not error, just redirect to home (where the recreate option is shown)
go.walletHome();
} else if (err && err.cors == 'rejected') {
$log.debug('CORS error:', err);
} else if (err.code === 'ETIMEDOUT') {
$log.debug('Time out:', err);
} else {
self.clientError = err;
}