diff options
author | Michał Sałaban <michal@salaban.info> | 2017-11-15 15:11:38 +0100 |
---|---|---|
committer | Michał Sałaban <michal@salaban.info> | 2017-11-15 16:35:14 +0100 |
commit | 0d149f708f146f64212330088619dd6a9f98b572 (patch) | |
tree | 56393592653f00669eff961d1779249fcddd5b80 /src/wallet/wallet2.cpp | |
parent | Merge pull request #2818 (diff) | |
download | monero-0d149f708f146f64212330088619dd6a9f98b572.tar.xz |
Add out-of-bound exceptions and handle them in RPC
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r-- | src/wallet/wallet2.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 00b096b88..019581f19 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -644,8 +644,7 @@ void wallet2::add_subaddress_account(const std::string& label) //---------------------------------------------------------------------------------------------------- void wallet2::add_subaddress(uint32_t index_major, const std::string& label) { - if (index_major >= m_subaddress_labels.size()) - throw std::runtime_error("index_major is out of bound"); + THROW_WALLET_EXCEPTION_IF(index_major >= m_subaddress_labels.size(), error::account_index_outofbound); uint32_t index_minor = (uint32_t)get_num_subaddresses(index_major); expand_subaddresses({index_major, index_minor}); m_subaddress_labels[index_major][index_minor] = label; @@ -701,10 +700,9 @@ std::string wallet2::get_subaddress_label(const cryptonote::subaddress_index& in //---------------------------------------------------------------------------------------------------- void wallet2::set_subaddress_label(const cryptonote::subaddress_index& index, const std::string &label) { - if (index.major >= m_subaddress_labels.size() || index.minor >= m_subaddress_labels[index.major].size()) - MERROR("Subaddress index is out of bounds. Failed to set subaddress label."); - else - m_subaddress_labels[index.major][index.minor] = label; + THROW_WALLET_EXCEPTION_IF(index.major >= m_subaddress_labels.size(), error::account_index_outofbound); + THROW_WALLET_EXCEPTION_IF(index.minor >= m_subaddress_labels[index.major].size(), error::address_index_outofbound); + m_subaddress_labels[index.major][index.minor] = label; } //---------------------------------------------------------------------------------------------------- /*! |