input/Plugin: migrate init() from class Error to C++ exceptions
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "../InputPlugin.hxx"
|
||||
#include "util/StringUtil.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "system/ByteOrder.hxx"
|
||||
@@ -105,8 +106,8 @@ static constexpr Domain cdio_domain("cdio");
|
||||
|
||||
static bool default_reverse_endian;
|
||||
|
||||
static InputPlugin::InitResult
|
||||
input_cdio_init(const ConfigBlock &block, Error &error)
|
||||
static void
|
||||
input_cdio_init(const ConfigBlock &block)
|
||||
{
|
||||
const char *value = block.GetBlockValue("default_byte_order");
|
||||
if (value != nullptr) {
|
||||
@@ -114,15 +115,10 @@ input_cdio_init(const ConfigBlock &block, Error &error)
|
||||
default_reverse_endian = IsBigEndian();
|
||||
else if (strcmp(value, "big_endian") == 0)
|
||||
default_reverse_endian = IsLittleEndian();
|
||||
else {
|
||||
error.Format(config_domain, 0,
|
||||
"Unrecognized 'default_byte_order' setting: %s",
|
||||
value);
|
||||
return InputPlugin::InitResult::ERROR;
|
||||
}
|
||||
else
|
||||
throw FormatRuntimeError("Unrecognized 'default_byte_order' setting: %s",
|
||||
value);
|
||||
}
|
||||
|
||||
return InputPlugin::InitResult::SUCCESS;
|
||||
}
|
||||
|
||||
struct cdio_uri {
|
||||
|
||||
@@ -533,8 +533,8 @@ CurlMulti::OnTimeout()
|
||||
*
|
||||
*/
|
||||
|
||||
static InputPlugin::InitResult
|
||||
input_curl_init(const ConfigBlock &block, gcc_unused Error &error)
|
||||
static void
|
||||
input_curl_init(const ConfigBlock &block)
|
||||
{
|
||||
CURLcode code = curl_global_init(CURL_GLOBAL_ALL);
|
||||
if (code != CURLE_OK)
|
||||
@@ -577,7 +577,6 @@ input_curl_init(const ConfigBlock &block, gcc_unused Error &error)
|
||||
}
|
||||
|
||||
curl_multi = new CurlMulti(io_thread_get(), multi);
|
||||
return InputPlugin::InitResult::SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -72,17 +72,14 @@ input_ffmpeg_supported(void)
|
||||
return avio_enum_protocols(&opaque, 0) != nullptr;
|
||||
}
|
||||
|
||||
static InputPlugin::InitResult
|
||||
input_ffmpeg_init(gcc_unused const ConfigBlock &block,
|
||||
gcc_unused Error &error)
|
||||
static void
|
||||
input_ffmpeg_init(gcc_unused const ConfigBlock &block)
|
||||
{
|
||||
FfmpegInit();
|
||||
|
||||
/* disable this plugin if there's no registered protocol */
|
||||
if (!input_ffmpeg_supported())
|
||||
throw PluginUnavailable("No protocol");
|
||||
|
||||
return InputPlugin::InitResult::SUCCESS;
|
||||
}
|
||||
|
||||
static InputStream *
|
||||
|
||||
@@ -215,11 +215,10 @@ NfsInputStream::OnNfsFileError(Error &&error)
|
||||
*
|
||||
*/
|
||||
|
||||
static InputPlugin::InitResult
|
||||
input_nfs_init(const ConfigBlock &, Error &)
|
||||
static void
|
||||
input_nfs_init(const ConfigBlock &)
|
||||
{
|
||||
nfs_init();
|
||||
return InputPlugin::InitResult::SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -68,8 +68,8 @@ public:
|
||||
*
|
||||
*/
|
||||
|
||||
static InputPlugin::InitResult
|
||||
input_smbclient_init(gcc_unused const ConfigBlock &block, gcc_unused Error &error)
|
||||
static void
|
||||
input_smbclient_init(gcc_unused const ConfigBlock &block)
|
||||
{
|
||||
try {
|
||||
SmbclientInit();
|
||||
@@ -81,8 +81,6 @@ input_smbclient_init(gcc_unused const ConfigBlock &block, gcc_unused Error &erro
|
||||
// TODO: create one global SMBCCTX here?
|
||||
|
||||
// TODO: evaluate ConfigBlock, call smbc_setOption*()
|
||||
|
||||
return InputPlugin::InitResult::SUCCESS;
|
||||
}
|
||||
|
||||
static InputStream *
|
||||
|
||||
Reference in New Issue
Block a user