better connection error handling

This commit is contained in:
Matias Alejo Garcia 2015-05-29 11:46:33 -03:00
commit 1fca607300
3 changed files with 31 additions and 11 deletions

View file

@ -214,6 +214,14 @@
<div class="large-12 columns"> <div class="large-12 columns">
<h2 class="text-center m10t" translate>My Bitcoin address</h2> <h2 class="text-center m10t" translate>My Bitcoin address</h2>
<div > <div >
<div class="box-notification" ng-show="home.addrError">
<span class="text-warning">
{{home.addrError|translate}}
</span>
</div>
<div class="text-center" ng-click="home.copyAddress(home.addr)"> <div class="text-center" ng-click="home.copyAddress(home.addr)">
<qrcode size="220" data="bitcoin:{{home.addr}}"></qrcode> <qrcode size="220" data="bitcoin:{{home.addr}}"></qrcode>
<div ng-show="home.generatingAddress" style="position:relative; top:-226px; height:0px"> <div ng-show="home.generatingAddress" style="position:relative; top:-226px; height:0px">

View file

@ -677,7 +677,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
go.walletHome(); go.walletHome();
} else if (err && err.cors == 'rejected') { } else if (err && err.cors == 'rejected') {
$log.debug('CORS error:', err); $log.debug('CORS error:', err);
} else if (err.code === 'ETIMEDOUT') { } else if (err.code === 'ETIMEDOUT' || err.code === 'CONNERROR') {
$log.debug('Time out:', err); $log.debug('Time out:', err);
} else { } else {
var msg = 'Error at Wallet Service: '; var msg = 'Error at Wallet Service: ';

View file

@ -91,9 +91,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
var parseError = function(err) { var parseError = function(err) {
if (err.message) { if (err.message) {
// TODO : this is not used anymore?
if (err.message.indexOf('CORS') >= 0) { if (err.message.indexOf('CORS') >= 0) {
err.message = gettext('Could not connect wallet service. Check your Internet connexion and your wallet service configuration.'); err.message = gettext('Could not connect wallet service. Check your Internet connexion and your wallet service configuration.');
} }
if (err.message.indexOf('TIMEDOUT') >= 0) { if (err.message.indexOf('TIMEDOUT') >= 0) {
err.message = gettext('Wallet service timed out. Check your Internet connexion and your wallet service configuration.'); err.message = gettext('Wallet service timed out. Check your Internet connexion and your wallet service configuration.');
} }
@ -200,7 +202,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
if (err) { if (err) {
$scope.loading = false; $scope.loading = false;
parseError(err); parseError(err);
$scope.error = err.message || gettext('Could not sign transaction. Please try again.'); $scope.error = err.message || gettext('Could not accept payment. Check you connection and try again');
$scope.$digest(); $scope.$digest();
} else { } else {
//if txp has required signatures then broadcast it //if txp has required signatures then broadcast it
@ -213,11 +215,15 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.loading = false; $scope.loading = false;
if (err) { if (err) {
parseError(err); parseError(err);
$scope.error = gettext('Could not broadcast transaction. Please try again.'); $scope.error = gettext('Could not broadcast payment. Check you connection and try again');
$scope.$digest(); $scope.$digest();
} else { } else {
console.log('[walletHome.js.219]'); //TODO
if (memo) if (memo)
$log.info(memo); $log.info(memo);
console.log('[walletHome.js.223]'); //TODO
$modalInstance.close(txpsb, true); $modalInstance.close(txpsb, true);
} }
}); });
@ -240,7 +246,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.loading = false; $scope.loading = false;
if (err) { if (err) {
parseError(err); parseError(err);
$scope.error = err.message || gettext('Could not reject transaction. Please try again.'); $scope.error = err.message || gettext('Could not reject payment. Check you connection and try again');
$scope.$digest(); $scope.$digest();
} else { } else {
$modalInstance.close(txpr); $modalInstance.close(txpr);
@ -262,7 +268,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
// Hacky: request tries to parse an empty response // Hacky: request tries to parse an empty response
if (err && !(err.message && err.message.match(/Unexpected/))) { if (err && !(err.message && err.message.match(/Unexpected/))) {
parseError(err); parseError(err);
$scope.error = err.message || gettext('Could not delete transaction. Please try again.'); $scope.error = err.message || gettext('Could not delete payment proposal. Check you connection and try again');
$scope.$digest(); $scope.$digest();
return; return;
} }
@ -281,7 +287,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.loading = false; $scope.loading = false;
if (err) { if (err) {
parseError(err); parseError(err);
$scope.error = err.message || gettext('Could not send transaction. Please try again.'); $scope.error = err.message || gettext('Could not broadcast payment. Check you connection and try again');
$scope.$digest(); $scope.$digest();
} else { } else {
@ -333,21 +339,24 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.setNewAddress = function() { this.setNewAddress = function() {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
self.generatingAddress = true; self.generatingAddress = true;
self.addrError = null;
fc.createAddress(function(err, addr) { fc.createAddress(function(err, addr) {
self.generatingAddress = false; self.generatingAddress = false;
if (err) { if (err) {
if (err.error.match(/locked/gi)) { if (err.error && err.error.match(/locked/gi)) {
$log.debug(err.error); $log.debug(err.error);
$timeout(function() { $timeout(function() {
self.setNewAddress(); self.setNewAddress();
}, 5000); }, 5000);
} else { } else {
$log.debug('Creating address ERROR:', err); $log.debug('Creating address ERROR:', err);
$scope.$emit('Local/ClientError', err); parseError(err);
self.addrError = err.message || gettext('Could not create address. Check you connection and try again');
$scope.$digest(); $scope.$digest();
} }
return; return;
} }
self.addrError = null;
self.addr = addr.address; self.addr = addr.address;
storageService.storeLastAddress(fc.credentials.walletId, addr.address, function() { storageService.storeLastAddress(fc.credentials.walletId, addr.address, function() {
@ -358,6 +367,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}; };
this.setAddress = function() { this.setAddress = function() {
self.addrError = null;
if (self.addr) if (self.addr)
return; return;
@ -410,7 +421,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}; };
this.resetError = function() { this.resetError = function() {
this.error = this.success = null; this.error = this.success = null;
}; };
this.bindTouchDown = function(tries) { this.bindTouchDown = function(tries) {
@ -527,9 +538,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
$log.warn(err); $log.warn(err);
parseError(err); parseError(err);
var errMessage = 'The transaction' + (fc.credentials.m > 1 ? ' proposal' : '') + var errMessage =
fc.credentials.m > 1 ? gettext('Could not create payment proposal') : gettext('Could not send payment');
' could not be created: ' + (err.message ? err.message : err); errMessage = errMessage + '. ' + (err.message ? err.message : gettext('Check you connection and try again'));
this.error = errMessage; this.error = errMessage;