From 50e5244e2511636fc031e20029d4aa3c47bb9658 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 5 Sep 2016 11:27:55 +0200 Subject: [PATCH] input/Init: support C++ exceptions --- src/input/Init.cxx | 16 +++++++++++++--- 1 file 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 #include @@ -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: