error output on exceptions in commit thread

This commit is contained in:
Grant Limberg 2025-05-21 07:57:03 -07:00
parent 08b1ceb9a1
commit 3cef1b0842
No known key found for this signature in database
GPG key ID: 8F2F97D3BE8D7735

View file

@ -745,10 +745,13 @@ void CV2::commitThread()
std::string networkId;
try {
pqxx::work w(*c->c);
memberId = config["id"];
networkId = config["nwid"];
std::string cfgDump = OSUtils::jsonDump(config, 2);
fprintf(stderr, "Member save %s-%s: %s\n", networkId.c_str(), memberId.c_str(), cfgDump.c_str());
std::string target = "NULL";
if (!config["remoteTraceTarget"].is_null()) {
target = config["remoteTraceTarget"];
@ -846,6 +849,12 @@ void CV2::commitThread()
} else {
fprintf(stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt);
}
} catch (pqxx::data_exception &e) {
const pqxx::sql_error *s=dynamic_cast<const pqxx::sql_error *>(&e);
fprintf(stderr, "%s ERROR: Error updating member: %s\n", _myAddressStr.c_str(), e.what());
if (s) {
fprintf(stderr, "%s ERROR: SQL error: %s\n", _myAddressStr.c_str(), s->query().c_str());
}
} catch (std::exception &e) {
fprintf(stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), networkId.c_str(), memberId.c_str(), e.what());
}
@ -882,6 +891,12 @@ void CV2::commitThread()
} else {
fprintf(stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt);
}
} catch (pqxx::data_exception &e) {
const pqxx::sql_error *s=dynamic_cast<const pqxx::sql_error *>(&e);
fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what());
if (s) {
fprintf(stderr, "%s ERROR: SQL error: %s\n", _myAddressStr.c_str(), s->query().c_str());
}
} catch (std::exception &e) {
fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what());
}