Skip to content

Commit

Permalink
Insert exception what() value in logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ksedgwic committed Aug 19, 2024
1 parent 39a09c2 commit 4a2ea4a
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 41 deletions.
10 changes: 6 additions & 4 deletions Boss/Mod/ChannelCreateDestroyMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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? */
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Boss/Mod/ChannelCreator/Carpenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,15 @@ Carpenter::construct(std::map<Ln::NodeId, Ln::Amount> 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()
);
}

Expand Down
5 changes: 3 additions & 2 deletions Boss/Mod/ChannelFinderByEarnedFee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions Boss/Mod/ChannelFinderByListpays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,13 @@ Ev::Io<void> 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()
);
}
});
Expand Down
8 changes: 4 additions & 4 deletions Boss/Mod/FeeModderByBalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions Boss/Mod/FeeModderBySize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
5 changes: 3 additions & 2 deletions Boss/Mod/ForwardFeeMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}

Expand Down
8 changes: 4 additions & 4 deletions Boss/Mod/FundsMover/Attempter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,15 @@ class Attempter::Impl : public std::enable_shared_from_this<Impl> {
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()
);
}

Expand Down
10 changes: 6 additions & 4 deletions Boss/Mod/FundsMover/Runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ Ev::Io<void> 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();
Expand Down Expand Up @@ -134,11 +135,12 @@ Ev::Io<void> 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();
Expand Down
5 changes: 3 additions & 2 deletions Boss/Mod/JitRebalancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions Boss/Mod/PaymentDeleter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
);
}
});
Expand Down
8 changes: 4 additions & 4 deletions Boss/Mod/PeerJudge/DataGatherer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 4a2ea4a

Please sign in to comment.