From 4a2ea4a0393e339f6eae9d773278717e859c99cc Mon Sep 17 00:00:00 2001 From: Ken Sedgwick Date: Fri, 26 Jul 2024 12:15:52 -0700 Subject: [PATCH] Insert exception what() value in logging messages --- Boss/Mod/ChannelCreateDestroyMonitor.cpp | 10 ++++++---- Boss/Mod/ChannelCreator/Carpenter.cpp | 5 +++-- Boss/Mod/ChannelFinderByEarnedFee.cpp | 5 +++-- Boss/Mod/ChannelFinderByListpays.cpp | 5 +++-- Boss/Mod/FeeModderByBalance.cpp | 8 ++++---- Boss/Mod/FeeModderBySize.cpp | 8 ++++---- Boss/Mod/ForwardFeeMonitor.cpp | 5 +++-- Boss/Mod/FundsMover/Attempter.cpp | 8 ++++---- Boss/Mod/FundsMover/Runner.cpp | 10 ++++++---- Boss/Mod/JitRebalancer.cpp | 5 +++-- Boss/Mod/PaymentDeleter.cpp | 14 +++++++------- Boss/Mod/PeerJudge/DataGatherer.cpp | 8 ++++---- 12 files changed, 50 insertions(+), 41 deletions(-) diff --git a/Boss/Mod/ChannelCreateDestroyMonitor.cpp b/Boss/Mod/ChannelCreateDestroyMonitor.cpp index bce644257..d06210753 100644 --- a/Boss/Mod/ChannelCreateDestroyMonitor.cpp +++ b/Boss/Mod/ChannelCreateDestroyMonitor.cpp @@ -149,12 +149,13 @@ void ChannelCreateDestroyMonitor::start() { try { auto payload = params["channel_opened"]; n = Ln::NodeId(std::string(payload["id"])); - } catch (std::runtime_error const&) { + } catch (std::runtime_error const& err) { return Boss::log( bus, Error , "ChannelCreateDestroyMonitor: " "Unexpected channel_opened " - "payload: %s" + "payload: %s: %s" , Util::stringify(params).c_str() + , err.what() ); } /* Is it already in channeled? */ @@ -174,12 +175,13 @@ void ChannelCreateDestroyMonitor::start() { n = Ln::NodeId(std::string(payload["peer_id"])); old_state = std::string(payload["old_state"]); new_state = std::string(payload["new_state"]); - } catch (std::runtime_error const&) { + } catch (std::runtime_error const& err) { return Boss::log( bus, Error , "ChannelCreateDestroyMonitor: " "Unexpected channel_state_changed " - "payload: %s" + "payload: %s: %s" , Util::stringify(params).c_str() + , err.what() ); } /* Only continue if we are leaving the CHANNELD_NORMAL diff --git a/Boss/Mod/ChannelCreator/Carpenter.cpp b/Boss/Mod/ChannelCreator/Carpenter.cpp index d430b6fcd..083978b43 100644 --- a/Boss/Mod/ChannelCreator/Carpenter.cpp +++ b/Boss/Mod/ChannelCreator/Carpenter.cpp @@ -157,14 +157,15 @@ Carpenter::construct(std::map plan) { report << ", "; report << node; } - } catch (std::invalid_argument const&) { + } catch (std::invalid_argument const& ex) { auto os = std::ostringstream(); os << res; return Boss::log( bus, Error , "ChannelCreator::Carpenter: " "Unexpected result from " - "multifundchannel: %s" + "multifundchannel: %s: %s" , os.str().c_str() + , ex.what() ); } diff --git a/Boss/Mod/ChannelFinderByEarnedFee.cpp b/Boss/Mod/ChannelFinderByEarnedFee.cpp index b3ee311fa..cf06ee774 100644 --- a/Boss/Mod/ChannelFinderByEarnedFee.cpp +++ b/Boss/Mod/ChannelFinderByEarnedFee.cpp @@ -131,12 +131,13 @@ class ChannelFinderByEarnedFee::Impl { continue; props.emplace(std::move(dest)); } - } catch (std::exception const&) { + } catch (std::exception const& ex) { return Boss::log( bus, Error , "ChannelFinderByEarnedFees: " "Unexpected result from " - "`listchannels`: %s" + "`listchannels`: %s: %s" , Util::stringify(res).c_str() + , ex.what() ); } res = Jsmn::Object(); diff --git a/Boss/Mod/ChannelFinderByListpays.cpp b/Boss/Mod/ChannelFinderByListpays.cpp index c3dd950b9..cad88b166 100644 --- a/Boss/Mod/ChannelFinderByListpays.cpp +++ b/Boss/Mod/ChannelFinderByListpays.cpp @@ -159,12 +159,13 @@ Ev::Io ChannelFinderByListpays::extract_payees_loop() { ++pit->second; ++count; return extract_payees_loop(); - } catch (std::exception const&) { + } catch (std::exception const& ex) { return Boss::log( bus, Error , "ChannelFinderByListpays: " "Unexpected result from `listpays` " - "`pays` field: %s" + "`pays` field: %s: %s" , Util::stringify(pay).c_str() + , ex.what() ); } }); diff --git a/Boss/Mod/FeeModderByBalance.cpp b/Boss/Mod/FeeModderByBalance.cpp index 79c292fd6..ec33c92e7 100644 --- a/Boss/Mod/FeeModderByBalance.cpp +++ b/Boss/Mod/FeeModderByBalance.cpp @@ -186,14 +186,14 @@ class FeeModderByBalance::Impl { ); break; } - } catch (std::exception const&) { + } catch (std::exception const& ex) { found = false; act = Boss::log( bus, Error , "FeeModderByBalance: " "Unexpected result from " - "listpeerchannels: %s" - , Util::stringify(res) - .c_str() + "listpeerchannels: %s: %s" + , Util::stringify(res).c_str() + , ex.what() ); } typedef ChannelSpecs CS; diff --git a/Boss/Mod/FeeModderBySize.cpp b/Boss/Mod/FeeModderBySize.cpp index 930863579..8fc133c2d 100644 --- a/Boss/Mod/FeeModderBySize.cpp +++ b/Boss/Mod/FeeModderBySize.cpp @@ -384,14 +384,14 @@ class FeeModderBySize::Impl { continue; rv.insert(n); } - } catch (std::exception const&) { + } catch (std::exception const& ex) { return Boss::log( bus, Error , "FeeModderBySize: " "get_competitors: " "Unexpected result from " - "listchannels: %s" - , Util::stringify(res) - .c_str() + "listchannels: %s: %s" + , Util::stringify(res).c_str() + , ex.what() ).then([rv]() { return Ev::lift(rv); }); diff --git a/Boss/Mod/ForwardFeeMonitor.cpp b/Boss/Mod/ForwardFeeMonitor.cpp index ddc815711..d3cb0b6cc 100644 --- a/Boss/Mod/ForwardFeeMonitor.cpp +++ b/Boss/Mod/ForwardFeeMonitor.cpp @@ -50,11 +50,12 @@ void ForwardFeeMonitor::start() { - double(payload["received_time"]) ; - } catch (std::runtime_error const& _) { + } catch (std::runtime_error const& err) { return Boss::log( bus, Error , "ForwardFeeMonitor: Unexpected " - "forward_event payload: %s" + "forward_event payload: %s: %s" , Util::stringify(n.params).c_str() + , err.what() ); } diff --git a/Boss/Mod/FundsMover/Attempter.cpp b/Boss/Mod/FundsMover/Attempter.cpp index 1849d033f..66223bbf3 100644 --- a/Boss/Mod/FundsMover/Attempter.cpp +++ b/Boss/Mod/FundsMover/Attempter.cpp @@ -348,15 +348,15 @@ class Attempter::Impl : public std::enable_shared_from_this { data["failcode"] )); } - } catch (std::exception const&) { + } catch (std::exception const& ex) { return std::move(act) + Boss::log( bus, Error , "FundsMover: Attempt: " "Unexpected error from " - "%s: %s" + "%s: %s: %s" , e.command.c_str() - , Util::stringify(e.error) - .c_str() + , Util::stringify(e.error).c_str() + , ex.what() ); } diff --git a/Boss/Mod/FundsMover/Runner.cpp b/Boss/Mod/FundsMover/Runner.cpp index 967c816bf..645b8d7f0 100644 --- a/Boss/Mod/FundsMover/Runner.cpp +++ b/Boss/Mod/FundsMover/Runner.cpp @@ -94,11 +94,12 @@ Ev::Io Runner::gather_info() { )); break; } - } catch (std::exception const&) { + } catch (std::exception const& ex) { return Boss::log( bus, Error , "FundsMover: Unexpected result " - "from listchannels: %s" + "from listchannels: %s: %s" , Util::stringify(res).c_str() + , ex.what() ); } return Ev::lift(); @@ -134,11 +135,12 @@ Ev::Io Runner::gather_info() { )); break; } - } catch (std::exception const&) { + } catch (std::exception const& ex) { return Boss::log( bus, Error , "FundsMover: Unexpected result " - "from listchannels: %s" + "from listchannels: %s: %s" , Util::stringify(res).c_str() + , ex.what() ); } return Ev::lift(); diff --git a/Boss/Mod/JitRebalancer.cpp b/Boss/Mod/JitRebalancer.cpp index 8735064a0..d50ea34a3 100644 --- a/Boss/Mod/JitRebalancer.cpp +++ b/Boss/Mod/JitRebalancer.cpp @@ -337,11 +337,12 @@ class JitRebalancer::Impl::Run::Impl { av.to_us += to_us; av.capacity += capacity; } - } catch (std::exception const&) { + } catch (std::exception const& ex) { return Boss::log( bus, Error , "JitRebalancer: Unexpected " - "result from listpeerchannels: %s" + "result from listpeerchannels: %s: %s" , Util::stringify(res).c_str() + , ex.what() ).then([]() { throw Continue(); return Ev::lift(); diff --git a/Boss/Mod/PaymentDeleter.cpp b/Boss/Mod/PaymentDeleter.cpp index 3a65d701a..a73c43366 100644 --- a/Boss/Mod/PaymentDeleter.cpp +++ b/Boss/Mod/PaymentDeleter.cpp @@ -108,12 +108,12 @@ class PaymentDeleter::Impl { try { pays = res["pays"]; it = pays.begin(); - } catch (std::exception const&) { + } catch (std::exception const& ex) { return Boss::log( bus, Error , "PaymentDeleter: Unexpected " - "result from 'listpays': " - "%s" + "result from 'listpays': %s: %s" , Util::stringify(res).c_str() + , ex.what() ); } return loop(); @@ -156,13 +156,13 @@ class PaymentDeleter::Impl { + delpay(payment_hash, status) + loop() ; - } catch (std::exception const&) { + } catch (std::exception const& ex) { return Boss::log( bus, Error , "PaymentDeleter: " "Unexpected 'pays' entry " - "from 'listpays': %s" - , Util::stringify(pay) - .c_str() + "from 'listpays': %s: %s" + , Util::stringify(pay).c_str() + , ex.what() ); } }); diff --git a/Boss/Mod/PeerJudge/DataGatherer.cpp b/Boss/Mod/PeerJudge/DataGatherer.cpp index 7746248b7..d9e6c11ae 100644 --- a/Boss/Mod/PeerJudge/DataGatherer.cpp +++ b/Boss/Mod/PeerJudge/DataGatherer.cpp @@ -90,13 +90,13 @@ class DataGatherer::Impl { id, total }); } - } catch (std::exception const& e) { + } catch (std::exception const& ex) { infos->clear(); return Boss::log( bus, Error , "PeerJudge: Unexpected " - "listpeers result: %s" - , Util::stringify(peers) - .c_str() + "listpeers result: %s: %s" + , Util::stringify(peers).c_str() + , ex.what() ); } return Ev::lift();