input/Init: support C++ exceptions
This commit is contained in:
parent
1c07f197de
commit
50e5244e25
@ -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)
|
|||||||
/* 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;
|
||||||
? plugin->init(*block, error)
|
|
||||||
: InputPlugin::InitResult::SUCCESS;
|
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) {
|
switch (result) {
|
||||||
case InputPlugin::InitResult::SUCCESS:
|
case InputPlugin::InitResult::SUCCESS:
|
||||||
|
Loading…
Reference in New Issue
Block a user