Improve sending error messages

Ideally these should be moved to the translation strings
This commit is contained in:
Justin Ehrenhofer 2023-04-07 08:54:39 -05:00
parent a3622fa90c
commit 6c0401089a
3 changed files with 7 additions and 7 deletions

View file

@ -6,5 +6,5 @@ class BitcoinTransactionWrongBalanceException implements Exception {
final CryptoCurrency currency; final CryptoCurrency currency;
@override @override
String toString() => 'Wrong balance. Not enough ${currency.title} on your balance.'; String toString() => 'You do not have enough ${currency.title} to send this amount.';
} }

View file

@ -166,14 +166,14 @@ abstract class HavenWalletBase extends WalletBase<MoneroBalance,
if (hasMultiDestination) { if (hasMultiDestination) {
if (outputs.any((item) => item.sendAll if (outputs.any((item) => item.sendAll
|| (item.formattedCryptoAmount ?? 0) <= 0)) { || (item.formattedCryptoAmount ?? 0) <= 0)) {
throw HavenTransactionCreationException('Wrong balance. Not enough XMR on your balance.'); throw HavenTransactionCreationException('You do not have enough coins to send this amount.');
} }
final int totalAmount = outputs.fold(0, (acc, value) => final int totalAmount = outputs.fold(0, (acc, value) =>
acc + (value.formattedCryptoAmount ?? 0)); acc + (value.formattedCryptoAmount ?? 0));
if (unlockedBalance < totalAmount) { if (unlockedBalance < totalAmount) {
throw HavenTransactionCreationException('Wrong balance. Not enough XMR on your balance.'); throw HavenTransactionCreationException('You do not have enough coins to send this amount.');
} }
final moneroOutputs = outputs.map((output) => final moneroOutputs = outputs.map((output) =>
@ -204,7 +204,7 @@ abstract class HavenWalletBase extends WalletBase<MoneroBalance,
final formattedBalance = moneroAmountToString(amount: unlockedBalance); final formattedBalance = moneroAmountToString(amount: unlockedBalance);
throw HavenTransactionCreationException( throw HavenTransactionCreationException(
'Incorrect unlocked balance. Unlocked: $formattedBalance. Transaction amount: ${output.cryptoAmount}.'); 'You do not have enough unlocked balance. Unlocked: $formattedBalance. Transaction amount: ${output.cryptoAmount}.');
} }
pendingTransactionDescription = pendingTransactionDescription =

View file

@ -180,14 +180,14 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
if (hasMultiDestination) { if (hasMultiDestination) {
if (outputs.any((item) => item.sendAll if (outputs.any((item) => item.sendAll
|| (item.formattedCryptoAmount ?? 0) <= 0)) { || (item.formattedCryptoAmount ?? 0) <= 0)) {
throw MoneroTransactionCreationException('Wrong balance. Not enough XMR on your balance.'); throw MoneroTransactionCreationException('You do not have enough XMR to send this amount.');
} }
final int totalAmount = outputs.fold(0, (acc, value) => final int totalAmount = outputs.fold(0, (acc, value) =>
acc + (value.formattedCryptoAmount ?? 0)); acc + (value.formattedCryptoAmount ?? 0));
if (unlockedBalance < totalAmount) { if (unlockedBalance < totalAmount) {
throw MoneroTransactionCreationException('Wrong balance. Not enough XMR on your balance.'); throw MoneroTransactionCreationException('You do not have enough XMR to send this amount.');
} }
final moneroOutputs = outputs.map((output) { final moneroOutputs = outputs.map((output) {
@ -222,7 +222,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
final formattedBalance = moneroAmountToString(amount: unlockedBalance); final formattedBalance = moneroAmountToString(amount: unlockedBalance);
throw MoneroTransactionCreationException( throw MoneroTransactionCreationException(
'Incorrect unlocked balance. Unlocked: $formattedBalance. Transaction amount: ${output.cryptoAmount}.'); 'You do not have enough unlocked balance. Unlocked: $formattedBalance. Transaction amount: ${output.cryptoAmount}.');
} }
pendingTransactionDescription = pendingTransactionDescription =