Translates errors from send

This commit is contained in:
Gustavo Maximiliano Cortez 2015-08-13 16:47:10 -03:00
commit ec471bdba3
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
2 changed files with 34 additions and 35 deletions

View file

@ -249,7 +249,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.setOngoingProcess(); self.setOngoingProcess();
if (err) { if (err) {
$scope.loading = false; $scope.loading = false;
$scope.error = bwsError.msg(err, gettext('Could not accept payment')); $scope.error = bwsError.msg(err, gettextCatalog.getString('Could not accept payment'));
$scope.$digest(); $scope.$digest();
} else { } else {
//if txp has required signatures then broadcast it //if txp has required signatures then broadcast it
@ -261,7 +261,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.setOngoingProcess(); self.setOngoingProcess();
$scope.loading = false; $scope.loading = false;
if (err) { if (err) {
$scope.error = bwsError.msg(err, gettext('Could not broadcast payment')); $scope.error = bwsError.msg(err, gettextCatalog.getString('Could not broadcast payment'));
$scope.$digest(); $scope.$digest();
} else { } else {
$log.debug('Transaction signed and broadcasted') $log.debug('Transaction signed and broadcasted')
@ -290,7 +290,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.setOngoingProcess(); self.setOngoingProcess();
$scope.loading = false; $scope.loading = false;
if (err) { if (err) {
$scope.error = bwsError.msg(err, gettext('Could not reject payment')); $scope.error = bwsError.msg(err, gettextCatalog.getString('Could not reject payment'));
$scope.$digest(); $scope.$digest();
} else { } else {
$modalInstance.close(txpr); $modalInstance.close(txpr);
@ -311,7 +311,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/))) {
$scope.error = bwsError.msg(err, gettext('Could not delete payment proposal')); $scope.error = bwsError.msg(err, gettextCatalog.getString('Could not delete payment proposal'));
$scope.$digest(); $scope.$digest();
return; return;
} }
@ -329,7 +329,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.setOngoingProcess(); self.setOngoingProcess();
$scope.loading = false; $scope.loading = false;
if (err) { if (err) {
$scope.error = bwsError.msg(err, gettext('Could not broadcast payment')); $scope.error = bwsError.msg(err, gettextCatalog.getString('Could not broadcast payment'));
$scope.$digest(); $scope.$digest();
} else { } else {
@ -657,7 +657,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.setSendError = function(err) { this.setSendError = function(err) {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
var prefix = var prefix =
fc.credentials.m > 1 ? gettext('Could not create payment proposal') : gettext('Could not send payment'); fc.credentials.m > 1 ? gettextCatalog.getString('Could not create payment proposal') : gettextCatalog.getString('Could not send payment');
this.error = bwsError.msg(err, prefix); this.error = bwsError.msg(err, prefix);
@ -781,7 +781,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
profileService.lockFC(); profileService.lockFC();
self.setOngoingProcess(); self.setOngoingProcess();
if (err) { if (err) {
err.message = bwsError.msg(err, gettext('The payment was created but could not be signed. Please try again from home screen')); err.message = bwsError.msg(err, gettextCatalog.getString('The payment was created but could not be signed. Please try again from home screen'));
return cb(err); return cb(err);
} }
@ -790,7 +790,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
fc.broadcastTxProposal(signedTx, function(err, btx, memo) { fc.broadcastTxProposal(signedTx, function(err, btx, memo) {
self.setOngoingProcess(); self.setOngoingProcess();
if (err) { if (err) {
err.message = bwsError.msg(err, gettext('The payment was signed but could not be broadcasted. Please try again from home screen')); err.message = bwsError.msg(err, gettextCatalog.getString('The payment was signed but could not be broadcasted. Please try again from home screen'));
return cb(err); return cb(err);
} }
if (memo) if (memo)

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('bwsError', function bwcErrorService($log, gettext) { .factory('bwsError', function bwcErrorService($log, gettextCatalog) {
var root = {}; var root = {};
root.msg = function(err, prefix) { root.msg = function(err, prefix) {
@ -10,85 +10,84 @@ angular.module('copayApp.services')
if (err && err.code) { if (err && err.code) {
switch(err.code) { switch(err.code) {
case 'CONNECTION_ERROR': case 'CONNECTION_ERROR':
body = gettext('Network connection error'); body = gettextCatalog.getString('Network connection error');
break; break;
case 'NOT_FOUND': case 'NOT_FOUND':
body = gettext('Wallet service not found'); body = gettextCatalog.getString('Wallet service not found');
break; break;
case 'BAD_SIGNATURES': case 'BAD_SIGNATURES':
body = gettext('Signatures rejected by server'); body = gettextCatalog.getString('Signatures rejected by server');
break; break;
case 'COPAYER_DATA_MISMATCH': case 'COPAYER_DATA_MISMATCH':
body = gettext('Copayer data mismatch'); body = gettextCatalog.getString('Copayer data mismatch');
break; break;
case 'COPAYER_IN_WALLET': case 'COPAYER_IN_WALLET':
body = gettext('Copayer already in this wallet'); body = gettextCatalog.getString('Copayer already in this wallet');
break; break;
case 'COPAYER_REGISTERED': case 'COPAYER_REGISTERED':
body = gettext('Copayer already registered'); body = gettextCatalog.getString('Copayer already registered');
break; break;
case 'COPAYER_VOTED': case 'COPAYER_VOTED':
body = gettext('Copayer already voted on this spend proposal'); body = gettextCatalog.getString('Copayer already voted on this spend proposal');
break; break;
case 'DUST_AMOUNT': case 'DUST_AMOUNT':
body = gettext('Amount below dust threshold'); body = gettextCatalog.getString('Amount below dust threshold');
break; break;
case 'INCORRECT_ADDRESS_NETWORK': case 'INCORRECT_ADDRESS_NETWORK':
body = gettext('Incorrect address network'); body = gettextCatalog.getString('Incorrect address network');
break; break;
case 'INSUFFICIENT_FUNDS': case 'INSUFFICIENT_FUNDS':
body = gettext('Insufficient funds'); body = gettextCatalog.getString('Insufficient funds');
break; break;
case 'INSUFFICIENT_FUNDS_FOR_FEE': case 'INSUFFICIENT_FUNDS_FOR_FEE':
body = gettext('Insufficient funds for fee'); body = gettextCatalog.getString('Insufficient funds for fee');
break; break;
case 'INVALID_ADDRESS': case 'INVALID_ADDRESS':
body = gettext('Invalid address'); body = gettextCatalog.getString('Invalid address');
break; break;
case 'LOCKED_FUNDS': case 'LOCKED_FUNDS':
body = gettext('Funds are locked by pending spend proposals'); body = gettextCatalog.getString('Funds are locked by pending spend proposals');
break; break;
case 'NOT_AUTHORIZED': case 'NOT_AUTHORIZED':
body = gettext('Not authorized'); body = gettextCatalog.getString('Not authorized');
break; break;
case 'TX_ALREADY_BROADCASTED': case 'TX_ALREADY_BROADCASTED':
body = gettext('Transaction already broadcasted'); body = gettextCatalog.getString('Transaction already broadcasted');
break; break;
case 'TX_CANNOT_CREATE': case 'TX_CANNOT_CREATE':
body = gettext('Locktime in effect. Please wait to create a new spend proposal'); body = gettextCatalog.getString('Locktime in effect. Please wait to create a new spend proposal');
break; break;
case 'TX_CANNOT_REMOVE': case 'TX_CANNOT_REMOVE':
body = gettext('Locktime in effect. Please wait to remove this spend proposal'); body = gettextCatalog.getString('Locktime in effect. Please wait to remove this spend proposal');
break; break;
case 'TX_NOT_ACCEPTED': case 'TX_NOT_ACCEPTED':
body = gettext('Spend proposal is not accepted'); body = gettextCatalog.getString('Spend proposal is not accepted');
break; break;
case 'TX_NOT_FOUND': case 'TX_NOT_FOUND':
body = gettext('Spend proposal not found'); body = gettextCatalog.getString('Spend proposal not found');
break; break;
case 'TX_NOT_PENDING': case 'TX_NOT_PENDING':
body = gettext('The spend proposal is not pending'); body = gettextCatalog.getString('The spend proposal is not pending');
break; break;
case 'UPGRADE_NEEDED': case 'UPGRADE_NEEDED':
body = gettext('Please upgrade Copay to perform this action'); body = gettextCatalog.getString('Please upgrade Copay to perform this action');
break; break;
case 'WALLET_ALREADY_EXISTS': case 'WALLET_ALREADY_EXISTS':
body = gettext('Wallet already exists'); body = gettextCatalog.getString('Wallet already exists');
break; break;
case 'WALLET_FULL': case 'WALLET_FULL':
body = gettext('Wallet is full'); body = gettextCatalog.getString('Wallet is full');
break; break;
case 'WALLET_NOT_COMPLETE': case 'WALLET_NOT_COMPLETE':
body = gettext('Wallet is not complete'); body = gettextCatalog.getString('Wallet is not complete');
break; break;
case 'WALLET_NOT_FOUND': case 'WALLET_NOT_FOUND':
body = gettext('Wallet not found'); body = gettextCatalog.getString('Wallet not found');
break; break;
} }
} }
var msg = prefix + ( body ? ': ' + body : ''); var msg = prefix + ( body ? ': ' + body : '');
$log.warn("BWC ERROR:" + msg);
return msg; return msg;
}; };