From 193f8a2167dc66a8775b8d38472d1d09f9b628c4 Mon Sep 17 00:00:00 2001 From: GuillermoFloresV Date: Thu, 30 Mar 2023 14:17:35 -0700 Subject: [PATCH] Add try/catch for connection checks during an update --- src/update.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/update.cpp b/src/update.cpp index 880a0e1..4042365 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -488,6 +488,15 @@ void run_update(const ldp_options& opt, bool update_users) ldp_log lg(opt.lg_level, opt.console, opt.quiet, &(opt.dbinfo)); + try { + etymon::pgconn conn(opt.dbinfo); + etymon::pgconn_result(&conn, "\dt"); + } catch (runtime_error e) { + string s = e.what(); + lg.write(log_level::fatal, "server", "", "Could not establish connection to the database. Error: \"" + s + "\"", -1); + exit(1); + } + vector users; bool ok = read_users(opt, &lg, &users, update_users); if (update_users) {