input/Plugin: migrate init() from class Error to C++ exceptions
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
#include "Init.hxx"
|
||||
#include "Registry.hxx"
|
||||
#include "InputPlugin.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "config/ConfigGlobal.hxx"
|
||||
#include "config/ConfigOption.hxx"
|
||||
#include "config/Block.hxx"
|
||||
@@ -33,8 +32,8 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
bool
|
||||
input_stream_global_init(Error &error)
|
||||
void
|
||||
input_stream_global_init()
|
||||
{
|
||||
const ConfigBlock empty;
|
||||
|
||||
@@ -54,12 +53,9 @@ input_stream_global_init(Error &error)
|
||||
/* the plugin is disabled in mpd.conf */
|
||||
continue;
|
||||
|
||||
InputPlugin::InitResult result;
|
||||
|
||||
try {
|
||||
result = plugin->init != nullptr
|
||||
? plugin->init(*block, error)
|
||||
: InputPlugin::InitResult::SUCCESS;
|
||||
if (plugin->init != nullptr)
|
||||
plugin->init(*block);
|
||||
} catch (const PluginUnavailable &e) {
|
||||
FormatError(e,
|
||||
"Input plugin '%s' is unavailable",
|
||||
@@ -69,20 +65,7 @@ input_stream_global_init(Error &error)
|
||||
std::throw_with_nested(FormatRuntimeError("Failed to initialize input plugin '%s'",
|
||||
plugin->name));
|
||||
}
|
||||
|
||||
switch (result) {
|
||||
case InputPlugin::InitResult::SUCCESS:
|
||||
input_plugins_enabled[i] = true;
|
||||
break;
|
||||
|
||||
case InputPlugin::InitResult::ERROR:
|
||||
error.FormatPrefix("Failed to initialize input plugin '%s': ",
|
||||
plugin->name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void input_stream_global_finish(void)
|
||||
|
||||
Reference in New Issue
Block a user