From ad91f74acd12a6f33baf360cfdee700e7b6e3793 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 16 Oct 2019 15:51:00 +0800 Subject: [PATCH] add try catch to MicroCore::get_tx --- src/MicroCore.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/MicroCore.cpp b/src/MicroCore.cpp index 6d46db5..be2a723 100644 --- a/src/MicroCore.cpp +++ b/src/MicroCore.cpp @@ -137,13 +137,21 @@ MicroCore::get_tx(const crypto::hash& tx_hash, transaction& tx) if (m_blockchain_storage.have_tx(tx_hash)) { // get transaction with given hash - tx = m_blockchain_storage.get_db().get_tx(tx_hash); + try + { + tx = m_blockchain_storage.get_db().get_tx(tx_hash); + } + catch (TX_DNE const& e) + { + cerr << "MicroCore::get_tx: " << e.what() << endl; + return false; + } } else { cerr << "MicroCore::get_tx tx does not exist in blockchain: " << tx_hash << endl; return false; - } + } return true;