diff options
author | Max Kellermann <max@musicpd.org> | 2016-09-05 11:27:55 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-09-05 11:28:05 +0200 |
commit | 50e5244e2511636fc031e20029d4aa3c47bb9658 (patch) | |
tree | 913590e623f07d98dabf1b39ae0b213af0832bc4 /src/input/Init.cxx | |
parent | 1c07f197debe044a09c9ba6cb9d79377f40d541a (diff) |
input/Init: support C++ exceptions
Diffstat (limited to 'src/input/Init.cxx')
-rw-r--r-- | src/input/Init.cxx | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/input/Init.cxx b/src/input/Init.cxx index a3cc55451..d47f8cea3 100644 --- a/src/input/Init.cxx +++ b/src/input/Init.cxx @@ -26,6 +26,9 @@ #include "config/ConfigOption.hxx" #include "config/Block.hxx" #include "Log.hxx" +#include "util/RuntimeError.hxx" + +#include <stdexcept> #include <assert.h> @@ -50,9 +53,16 @@ input_stream_global_init(Error &error) /* the plugin is disabled in mpd.conf */ continue; - InputPlugin::InitResult result = plugin->init != nullptr - ? plugin->init(*block, error) - : InputPlugin::InitResult::SUCCESS; + InputPlugin::InitResult result; + + try { + result = plugin->init != nullptr + ? plugin->init(*block, error) + : InputPlugin::InitResult::SUCCESS; + } catch (const std::runtime_error &e) { + std::throw_with_nested(FormatRuntimeError("Failed to initialize input plugin '%s'", + plugin->name)); + } switch (result) { case InputPlugin::InitResult::SUCCESS: |