From 9a67af7c55ad8b49d1380e871c50391042be0b37 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 4 Nov 2024 00:20:05 +0800 Subject: [PATCH] code refactor --- src/components/desktop/AmountInput.vue | 8 +++++--- src/views/desktop/ExchangeRatesPage.vue | 4 ++-- src/views/desktop/transactions/ListPage.vue | 2 +- src/views/mobile/transactions/AmountFilterPage.vue | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/desktop/AmountInput.vue b/src/components/desktop/AmountInput.vue index ea3d97ff..b28c5d07 100644 --- a/src/components/desktop/AmountInput.vue +++ b/src/components/desktop/AmountInput.vue @@ -36,6 +36,7 @@ import { useUserStore } from '@/stores/user.js'; import transactionConstants from '@/consts/transaction.js'; import { removeAll } from '@/lib/common.js'; +import logger from '@/lib/logger.js'; export default { props: [ @@ -75,7 +76,8 @@ export default { } return (val >= transactionConstants.minAmountNumber && val <= transactionConstants.maxAmountNumber) || self.$t('Amount value exceeds limitation'); - } catch (e) { + } catch (ex) { + logger.warn('cannot parse amount in amount input, original value is ' + v, ex); return self.$t('Amount value is not number'); } } @@ -249,8 +251,8 @@ export default { this.currentValue = finalValue; e.preventDefault(); } - } catch (e) { - e.target.value = '0'; + } catch (ex) { + ex.target.value = '0'; } }, onPaste(e) { diff --git a/src/views/desktop/ExchangeRatesPage.vue b/src/views/desktop/ExchangeRatesPage.vue index b4d27a38..f5a78c87 100644 --- a/src/views/desktop/ExchangeRatesPage.vue +++ b/src/views/desktop/ExchangeRatesPage.vue @@ -245,9 +245,9 @@ export default { try { exchangeRateAmount = getConvertedAmount(this.baseAmount / 100, fromExchangeRate, toExchangeRate); - } catch (e) { + } catch (ex) { exchangeRateAmount = 0; - logger.warn('failed to convert amount by exchange rates, original base amount is ' + this.baseAmount) + logger.warn('failed to convert amount by exchange rates, original base amount is ' + this.baseAmount, ex) } return this.$locale.formatExchangeRateAmount(this.userStore, exchangeRateAmount); diff --git a/src/views/desktop/transactions/ListPage.vue b/src/views/desktop/transactions/ListPage.vue index 1797fb38..844c12c6 100644 --- a/src/views/desktop/transactions/ListPage.vue +++ b/src/views/desktop/transactions/ListPage.vue @@ -1448,7 +1448,7 @@ export default { amount2 = parseInt(filterItems[2]); } } catch (ex) { - logger.warn('cannot parse amount from filter value, original value is ' + this.query.amountFilter); + logger.warn('cannot parse amount from filter value, original value is ' + this.query.amountFilter, ex); } } diff --git a/src/views/mobile/transactions/AmountFilterPage.vue b/src/views/mobile/transactions/AmountFilterPage.vue index 4f9fee28..3c828fd0 100644 --- a/src/views/mobile/transactions/AmountFilterPage.vue +++ b/src/views/mobile/transactions/AmountFilterPage.vue @@ -133,7 +133,7 @@ export default { amount2 = parseInt(filterItems[2]); } } catch (ex) { - logger.warn('cannot parse amount from filter value, original value is ' + query.value); + logger.warn('cannot parse amount from filter value, original value is ' + query.value, ex); } }