From 1450e45d97aab94544f5e0e5d7c592edc9bba7a3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 23 Jan 2017 18:52:11 +0100 Subject: [PATCH] Main, db/Glue: improve error messages --- src/Main.cxx | 6 +++++- src/db/DatabaseGlue.cxx | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Main.cxx b/src/Main.cxx index e29f59c3d..0ea263a87 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -203,7 +203,11 @@ glue_db_init_and_load(void) "because the database does not need it"); } - instance->database->Open(); + try { + instance->database->Open(); + } catch (...) { + std::throw_with_nested(std::runtime_error("Failed to open database plugin")); + } if (!instance->database->IsPlugin(simple_db_plugin)) return true; diff --git a/src/db/DatabaseGlue.cxx b/src/db/DatabaseGlue.cxx index 8076633d1..401162114 100644 --- a/src/db/DatabaseGlue.cxx +++ b/src/db/DatabaseGlue.cxx @@ -37,5 +37,10 @@ DatabaseGlobalInit(EventLoop &loop, DatabaseListener &listener, throw FormatRuntimeError("No such database plugin: %s", plugin_name); - return plugin->create(loop, listener, block); + try { + return plugin->create(loop, listener, block); + } catch (...) { + std::throw_with_nested(FormatRuntimeError("Failed to initialize database plugin '%s'", + plugin_name)); + } }