Browse Source

error output on exceptions in commit thread

Grant Limberg 2 months ago
parent
commit
3cef1b0842
1 changed files with 16 additions and 1 deletions
  1. 16 1
      controller/CV2.cpp

+ 16 - 1
controller/CV2.cpp

@@ -745,10 +745,13 @@ void CV2::commitThread()
 				std::string networkId;
 				std::string networkId;
 				try {
 				try {
 					pqxx::work w(*c->c);
 					pqxx::work w(*c->c);
-
+					
 					memberId = config["id"];
 					memberId = config["id"];
 					networkId = config["nwid"];
 					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";
 					std::string target = "NULL";
 					if (!config["remoteTraceTarget"].is_null()) {
 					if (!config["remoteTraceTarget"].is_null()) {
 						target = config["remoteTraceTarget"];
 						target = config["remoteTraceTarget"];
@@ -846,6 +849,12 @@ void CV2::commitThread()
 					} else {
 					} 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);
 						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) {
 				} 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());
 					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 {
 					} else {
 						fprintf(stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt);
 						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) {
 				} catch (std::exception &e) {
 					fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what());
 					fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what());
 				}
 				}