diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index beaa7612..b80d01d5 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -62,9 +62,7 @@ namespace ph = boost::placeholders; } \ catch (const tools::error::not_enough_money& e) \ { \ - fail_msg_writer() << "not enough money to transfer, available only " << print_money(e.available()) << \ - ", transaction amount " << print_money(e.tx_amount() + e.fee()) << " = " << print_money(e.tx_amount()) << \ - " + " << print_money(e.fee()) << " (fee)"; \ + fail_msg_writer() << "not enough money to transfer, " << e.to_string(); \ } \ catch (const tools::error::not_enough_outs_to_mix& e) \ { \ diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 618fe84e..f34b23e9 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -5603,7 +5603,7 @@ bool wallet2::accept_ionic_swap_proposal(const wallet_public::ionic_swap_proposa { if (balances[item.asset_id].unlocked < item.amount) { - return false; + WLT_THROW_IF_FALSE_WALLET_EX_MES(false, error::not_enough_money, "", balances[item.asset_id].unlocked, item.amount, 0 /*fee*/, item.asset_id); } if (item.asset_id == currency::native_coin_asset_id) { @@ -5618,7 +5618,7 @@ bool wallet2::accept_ionic_swap_proposal(const wallet_public::ionic_swap_proposa additional_fee = m_core_runtime_config.tx_default_fee - msc.proposal_info.fee_paid_by_a; if (balances[currency::native_coin_asset_id].unlocked < additional_fee + native_amount_required) { - return false; + WLT_THROW_IF_FALSE_WALLET_EX_MES(false, error::not_enough_money, "", balances[currency::native_coin_asset_id].unlocked, native_amount_required, additional_fee, currency::native_coin_asset_id); } } diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h index 9e8426c0..07cb7f22 100644 --- a/src/wallet/wallet_errors.h +++ b/src/wallet/wallet_errors.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "currency_core/currency_format_utils.h" #include "rpc/core_rpc_server_commands_defs.h" @@ -70,10 +71,10 @@ namespace tools std::string to_string() const { std::ostringstream ss; - ss << m_loc << ':' << typeid(*this).name(); + ss << m_loc << '[' << boost::replace_all_copy(std::string(typeid(*this).name()), "struct ", ""); if (!m_error_code.empty()) ss << "[" << m_error_code << "]"; - ss << ": " << Base::what(); + ss << "] " << Base::what(); return ss.str(); } @@ -350,7 +351,7 @@ namespace tools struct not_enough_money : public transfer_error { not_enough_money(std::string&& loc, uint64_t availbable, uint64_t tx_amount, uint64_t fee, const crypto::public_key& asset_id) - : transfer_error(std::move(loc), "NOT_ENOUGH_MONEY") + : transfer_error(std::move(loc), "") , m_available(availbable) , m_tx_amount(tx_amount) , m_fee(fee) @@ -366,11 +367,11 @@ namespace tools { std::ostringstream ss; ss << transfer_error::to_string() << - ", available = " << currency::print_money(m_available) << - ", tx_amount = " << currency::print_money(m_tx_amount) << - ", fee = " << currency::print_money(m_fee); + "available: " << currency::print_money_brief(m_available) << + ", required: " << currency::print_money_brief(m_tx_amount + m_fee) << + " = " << currency::print_money_brief(m_tx_amount) << " + " << currency::print_money_brief(m_fee) << " (fee)"; if (m_asset_id != currency::native_coin_asset_id) - ss << ", asset_id = " << m_asset_id; + ss << ", asset_id: " << m_asset_id; return ss.str(); }