Commit 50e5244e authored by Max Kellermann's avatar Max Kellermann

input/Init: support C++ exceptions

parent 1c07f197
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include "config/ConfigOption.hxx" #include "config/ConfigOption.hxx"
#include "config/Block.hxx" #include "config/Block.hxx"
#include "Log.hxx" #include "Log.hxx"
#include "util/RuntimeError.hxx"
#include <stdexcept>
#include <assert.h> #include <assert.h>
...@@ -50,9 +53,16 @@ input_stream_global_init(Error &error) ...@@ -50,9 +53,16 @@ input_stream_global_init(Error &error)
/* the plugin is disabled in mpd.conf */ /* the plugin is disabled in mpd.conf */
continue; continue;
InputPlugin::InitResult result = plugin->init != nullptr InputPlugin::InitResult result;
try {
result = plugin->init != nullptr
? plugin->init(*block, error) ? plugin->init(*block, error)
: InputPlugin::InitResult::SUCCESS; : InputPlugin::InitResult::SUCCESS;
} catch (const std::runtime_error &e) {
std::throw_with_nested(FormatRuntimeError("Failed to initialize input plugin '%s'",
plugin->name));
}
switch (result) { switch (result) {
case InputPlugin::InitResult::SUCCESS: case InputPlugin::InitResult::SUCCESS:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment