Merge pull request #5028 from gabrielbazan7/fix/handleError
better error handler
This commit is contained in:
commit
0a7ba4bd02
5 changed files with 20 additions and 66 deletions
|
|
@ -196,8 +196,11 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
lodash.each($scope.wallets, function(wallet) {
|
lodash.each($scope.wallets, function(wallet) {
|
||||||
walletService.getStatus(wallet, {}, function(err, status) {
|
walletService.getStatus(wallet, {}, function(err, status) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
if (err === 'WALLET_NOT_REGISTERED') wallet.error = gettextCatalog.getString('Wallet not registered');
|
||||||
|
else wallet.error = gettextCatalog.getString('Could not update');;
|
||||||
$log.error(err);
|
$log.error(err);
|
||||||
} else {
|
} else {
|
||||||
|
wallet.error = null;
|
||||||
wallet.status = status;
|
wallet.status = status;
|
||||||
}
|
}
|
||||||
if (++j == i) {
|
if (++j == i) {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
|
|
||||||
var updateStatus = function(force) {
|
var updateStatus = function(force) {
|
||||||
$scope.updatingStatus = true;
|
$scope.updatingStatus = true;
|
||||||
$scope.updateStatusError = false;
|
$scope.updateStatusError = null;
|
||||||
$scope.walletNotRegistered = false;
|
$scope.walletNotRegistered = false;
|
||||||
|
|
||||||
walletService.getStatus($scope.wallet, {
|
walletService.getStatus($scope.wallet, {
|
||||||
|
|
@ -57,18 +57,16 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
if (err === 'WALLET_NOT_REGISTERED') {
|
if (err === 'WALLET_NOT_REGISTERED') {
|
||||||
$scope.walletNotRegistered = true;
|
$scope.walletNotRegistered = true;
|
||||||
} else {
|
} else {
|
||||||
$scope.updateStatusError = true;
|
$scope.updateStatusError = err;
|
||||||
}
|
}
|
||||||
$scope.status = null;
|
$scope.status = null;
|
||||||
return;
|
} else {
|
||||||
|
setPendingTxps(status.pendingTxps);
|
||||||
|
$scope.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPendingTxps(status.pendingTxps);
|
|
||||||
|
|
||||||
$scope.status = status;
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}, 1);
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -111,6 +109,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
if (err) return;
|
if (err) return;
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
walletService.startScan($scope.wallet, function() {
|
walletService.startScan($scope.wallet, function() {
|
||||||
|
$scope.updateAll();
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -57,32 +57,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO
|
|
||||||
// This handles errors from BWS/index which normally
|
|
||||||
// trigger from async events (like updates).
|
|
||||||
// Debounce function avoids multiple popups
|
|
||||||
var _handleError = function(err) {
|
|
||||||
$log.warn('wallet ERROR: ', err);
|
|
||||||
|
|
||||||
$log.warn('TODO');
|
|
||||||
return; // TODO!!!
|
|
||||||
if (err instanceof errors.NOT_AUTHORIZED) {
|
|
||||||
|
|
||||||
console.log('[walletService.js.93] TODO NOT AUTH'); //TODO
|
|
||||||
// TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
|
|
||||||
wallet.notAuthorized = true;
|
|
||||||
$state.go('tabs.home');
|
|
||||||
} else if (err instanceof errors.NOT_FOUND) {
|
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not access Wallet Service: Not found'));
|
|
||||||
} else {
|
|
||||||
var msg = ""
|
|
||||||
$rootScope.$emit('Local/ClientError', (err.error ? err.error : err));
|
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, gettextCatalog.getString('Error at Wallet Service')));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
root.handleError = lodash.debounce(_handleError, 1000);
|
|
||||||
|
|
||||||
|
|
||||||
root.invalidateCache = function(wallet) {
|
root.invalidateCache = function(wallet) {
|
||||||
if (wallet.cachedStatus)
|
if (wallet.cachedStatus)
|
||||||
wallet.cachedStatus.isValid = false;
|
wallet.cachedStatus.isValid = false;
|
||||||
|
|
@ -210,7 +184,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
cache.totalBalanceStr = txFormatService.formatAmount(cache.totalBalanceSat) + ' ' + cache.unitName;
|
cache.totalBalanceStr = txFormatService.formatAmount(cache.totalBalanceSat) + ' ' + cache.unitName;
|
||||||
cache.lockedBalanceStr = txFormatService.formatAmount(cache.lockedBalanceSat) + ' ' + cache.unitName;
|
cache.lockedBalanceStr = txFormatService.formatAmount(cache.lockedBalanceSat) + ' ' + cache.unitName;
|
||||||
cache.availableBalanceStr = txFormatService.formatAmount(cache.availableBalanceSat) + ' ' + cache.unitName;
|
cache.availableBalanceStr = txFormatService.formatAmount(cache.availableBalanceSat) + ' ' + cache.unitName;
|
||||||
cache.pendingBalanceStr = txFormatService.formatAmount(cache.totalBalanceSat + (cache.pendingAmount === null? 0 : cache.pendingAmount)) + ' ' + cache.unitName;
|
cache.pendingBalanceStr = txFormatService.formatAmount(cache.totalBalanceSat + (cache.pendingAmount === null ? 0 : cache.pendingAmount)) + ' ' + cache.unitName;
|
||||||
|
|
||||||
if (cache.pendingAmount !== null && cache.pendingAmount !== 0) {
|
if (cache.pendingAmount !== null && cache.pendingAmount !== 0) {
|
||||||
cache.pendingAmountStr = txFormatService.formatAmount(cache.pendingAmount) + ' ' + cache.unitName;
|
cache.pendingAmountStr = txFormatService.formatAmount(cache.pendingAmount) + ' ' + cache.unitName;
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@
|
||||||
<span class="tab-home__wallet__multisig-number" ng-if="wallet.n > 1">
|
<span class="tab-home__wallet__multisig-number" ng-if="wallet.n > 1">
|
||||||
{{wallet.m}}-of-{{wallet.n}}
|
{{wallet.m}}-of-{{wallet.n}}
|
||||||
</span>
|
</span>
|
||||||
|
<span class="assertive" ng-if="wallet.error">{{wallet.error}}</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,11 @@
|
||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
<div class="oh pr" ng-show="wallet && wallet.isComplete()">
|
<div class="oh pr" ng-show="wallet && wallet.isComplete()">
|
||||||
<div ng-style="{'background-color':wallet.color}" class="amount">
|
<div ng-style="{'background-color':wallet.color}" class="amount">
|
||||||
<div ng-if="!notAuthorized && !updatingStatus">
|
<div ng-if="!updatingStatus">
|
||||||
|
|
||||||
<div ng-show="updateStatusError">
|
<div ng-show="updateStatusError">
|
||||||
<a class="button button-outline button-light button-small" ng-click='update()' translate>Tap to retry</a>
|
<span class="size-12 db m10b">{{updateStatusError}}</span>
|
||||||
|
<a class="button button-outline button-light button-small" ng-click='updateAll()' translate>Tap to retry</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="walletNotRegistered">
|
<div ng-show="walletNotRegistered">
|
||||||
|
|
@ -30,13 +31,7 @@
|
||||||
<a class="button button-outline button-light button-small" ng-click='recreate()' translate>Recreate</a>
|
<a class="button button-outline button-light button-small" ng-click='recreate()' translate>Recreate</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="wallet.walletScanStatus == 'error'" ng-click='retryScan()'>
|
<div ng-click='updateAll(true)' ng-show="!updateStatusError && !wallet.balanceHidden" on-hold="hideToggle()">
|
||||||
<span translate>Scan status finished with error</span>
|
|
||||||
<br><span translate>Tap to retry</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div ng-click='updateAll(true)' ng-show="!updateStatusError && wallet.walletScanStatus != 'error' && !wallet.balanceHidden" on-hold="hideToggle()">
|
|
||||||
<strong ng-if="!status.pendingAmount" class="size-36">{{status.totalBalanceStr}}</strong>
|
<strong ng-if="!status.pendingAmount" class="size-36">{{status.totalBalanceStr}}</strong>
|
||||||
<div ng-if="!status.pendingAmount" class="size-14 amount-alternative" ng-if="status.totalBalanceAlternative">{{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}</div>
|
<div ng-if="!status.pendingAmount" class="size-14 amount-alternative" ng-if="status.totalBalanceAlternative">{{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}</div>
|
||||||
<div class="size-20" ng-if="status.pendingAmount">
|
<div class="size-20" ng-if="status.pendingAmount">
|
||||||
|
|
@ -45,7 +40,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="!updateStatusError && wallet.walletScanStatus != 'error' && wallet.balanceHidden" on-hold="hideToggle()">
|
<div ng-show="!updateStatusError && wallet.balanceHidden" on-hold="hideToggle()">
|
||||||
<strong class="size-24" translate>[Balance Hidden]</strong>
|
<strong class="size-24" translate>[Balance Hidden]</strong>
|
||||||
<div class="size-14" translate>
|
<div class="size-14" translate>
|
||||||
Tap and hold to show
|
Tap and hold to show
|
||||||
|
|
@ -64,7 +59,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- oh -->
|
</div> <!-- oh -->
|
||||||
|
|
||||||
<div class="p60b" ng-show="wallet && wallet.isComplete()">
|
<div class="p60b" ng-show="wallet && wallet.isComplete() && !walletNotRegistered">
|
||||||
<div class="oh pr m20t" ng-show="wallet.incorrectDerivation">
|
<div class="oh pr m20t" ng-show="wallet.incorrectDerivation">
|
||||||
<div class="text-center text-warning">
|
<div class="text-center text-warning">
|
||||||
<i class="fi-alert"></i>
|
<i class="fi-alert"></i>
|
||||||
|
|
@ -73,25 +68,6 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="oh pr m20t" ng-show="notAuthorized && !updatingStatus">
|
|
||||||
<div class="text-center text-warning">
|
|
||||||
<i class="fi-alert"></i>
|
|
||||||
<span translate>
|
|
||||||
WARNING: Wallet not registered
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="text-center text-gray m15r m15l" translate>
|
|
||||||
This wallet is not registered at the given Bitcore Wallet Service (BWS). You can recreate it from the local information.
|
|
||||||
</div>
|
|
||||||
<div class="text-center m10t ">
|
|
||||||
<span class="button outline round dark-gray tiny"
|
|
||||||
ng-click="recreate()">
|
|
||||||
<span translate>Recreate</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="list" ng-if="txps[0]">
|
<div class="list" ng-if="txps[0]">
|
||||||
<div class="item item-heading" translate>
|
<div class="item item-heading" translate>
|
||||||
<span ng-show="requiresMultipleSignatures" translate>Payment Proposals</span>
|
<span ng-show="requiresMultipleSignatures" translate>Payment Proposals</span>
|
||||||
|
|
@ -110,7 +86,7 @@
|
||||||
<!-- Transactions -->
|
<!-- Transactions -->
|
||||||
|
|
||||||
<div class="oh pr m20t text-gray size-12 text-center"
|
<div class="oh pr m20t text-gray size-12 text-center"
|
||||||
ng-show="!txHistory[0] && !updatingTxHistory && !txHistoryError && !updateStatusError && !notAuthorized" translate>
|
ng-show="!txHistory[0] && !updatingTxHistory && !txHistoryError && !updateStatusError" translate>
|
||||||
No transactions yet
|
No transactions yet
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -178,5 +154,6 @@
|
||||||
on-infinite="showMore()"
|
on-infinite="showMore()"
|
||||||
distance="1%">
|
distance="1%">
|
||||||
</ion-infinite-scroll>
|
</ion-infinite-scroll>
|
||||||
|
</div>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
</ion-view>
|
</ion-view>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue