PluginUnavailable: add subclass PluginUnconfigured
PluginUnconfigured exceptions are logged with level "info" instead of "error". This suppresses some rather boring messages in the default log level. Closes https://github.com/MusicPlayerDaemon/MPD/issues/565
This commit is contained in:
parent
9d1906da8a
commit
40a48cfba0
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2018 The Music Player Daemon Project
|
* Copyright 2003-2019 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -27,11 +27,24 @@
|
|||||||
* that this plugin is unavailable. It will be disabled, and MPD can
|
* that this plugin is unavailable. It will be disabled, and MPD can
|
||||||
* continue initialization.
|
* continue initialization.
|
||||||
*/
|
*/
|
||||||
class PluginUnavailable final : public std::runtime_error {
|
class PluginUnavailable : public std::runtime_error {
|
||||||
public:
|
public:
|
||||||
template<typename M>
|
template<typename M>
|
||||||
explicit PluginUnavailable(M &&msg) noexcept
|
explicit PluginUnavailable(M &&msg) noexcept
|
||||||
:std::runtime_error(std::forward<M>(msg)) {}
|
:std::runtime_error(std::forward<M>(msg)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like #PluginUnavailable, but denotes that the plugin is not
|
||||||
|
* available because it was not explicitly enabled in the
|
||||||
|
* configuration. The message may describe the necessary steps to
|
||||||
|
* enable it.
|
||||||
|
*/
|
||||||
|
class PluginUnconfigured : public PluginUnavailable {
|
||||||
|
public:
|
||||||
|
template<typename M>
|
||||||
|
explicit PluginUnconfigured(M &&msg) noexcept
|
||||||
|
:PluginUnavailable(std::forward<M>(msg)) {}
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -58,6 +58,11 @@ input_stream_global_init(const ConfigData &config, EventLoop &event_loop)
|
|||||||
if (plugin->init != nullptr)
|
if (plugin->init != nullptr)
|
||||||
plugin->init(event_loop, *block);
|
plugin->init(event_loop, *block);
|
||||||
input_plugins_enabled[i] = true;
|
input_plugins_enabled[i] = true;
|
||||||
|
} catch (const PluginUnconfigured &e) {
|
||||||
|
LogFormat(LogLevel::INFO, e,
|
||||||
|
"Input plugin '%s' is not configured",
|
||||||
|
plugin->name);
|
||||||
|
continue;
|
||||||
} catch (const PluginUnavailable &e) {
|
} catch (const PluginUnavailable &e) {
|
||||||
FormatError(e,
|
FormatError(e,
|
||||||
"Input plugin '%s' is unavailable",
|
"Input plugin '%s' is unavailable",
|
||||||
|
@ -133,11 +133,11 @@ InitQobuzInput(EventLoop &event_loop, const ConfigBlock &block)
|
|||||||
|
|
||||||
const char *app_id = block.GetBlockValue("app_id");
|
const char *app_id = block.GetBlockValue("app_id");
|
||||||
if (app_id == nullptr)
|
if (app_id == nullptr)
|
||||||
throw PluginUnavailable("No Qobuz app_id configured");
|
throw PluginUnconfigured("No Qobuz app_id configured");
|
||||||
|
|
||||||
const char *app_secret = block.GetBlockValue("app_secret");
|
const char *app_secret = block.GetBlockValue("app_secret");
|
||||||
if (app_secret == nullptr)
|
if (app_secret == nullptr)
|
||||||
throw PluginUnavailable("No Qobuz app_secret configured");
|
throw PluginUnconfigured("No Qobuz app_secret configured");
|
||||||
|
|
||||||
const char *device_manufacturer_id = block.GetBlockValue("device_manufacturer_id",
|
const char *device_manufacturer_id = block.GetBlockValue("device_manufacturer_id",
|
||||||
"df691fdc-fa36-11e7-9718-635337d7df8f");
|
"df691fdc-fa36-11e7-9718-635337d7df8f");
|
||||||
@ -145,11 +145,11 @@ InitQobuzInput(EventLoop &event_loop, const ConfigBlock &block)
|
|||||||
const char *username = block.GetBlockValue("username");
|
const char *username = block.GetBlockValue("username");
|
||||||
const char *email = block.GetBlockValue("email");
|
const char *email = block.GetBlockValue("email");
|
||||||
if (username == nullptr && email == nullptr)
|
if (username == nullptr && email == nullptr)
|
||||||
throw PluginUnavailable("No Qobuz username configured");
|
throw PluginUnconfigured("No Qobuz username configured");
|
||||||
|
|
||||||
const char *password = block.GetBlockValue("password");
|
const char *password = block.GetBlockValue("password");
|
||||||
if (password == nullptr)
|
if (password == nullptr)
|
||||||
throw PluginUnavailable("No Qobuz password configured");
|
throw PluginUnconfigured("No Qobuz password configured");
|
||||||
|
|
||||||
const char *format_id = block.GetBlockValue("format_id", "5");
|
const char *format_id = block.GetBlockValue("format_id", "5");
|
||||||
|
|
||||||
|
@ -170,15 +170,15 @@ InitTidalInput(EventLoop &event_loop, const ConfigBlock &block)
|
|||||||
|
|
||||||
const char *token = block.GetBlockValue("token");
|
const char *token = block.GetBlockValue("token");
|
||||||
if (token == nullptr)
|
if (token == nullptr)
|
||||||
throw PluginUnavailable("No Tidal application token configured");
|
throw PluginUnconfigured("No Tidal application token configured");
|
||||||
|
|
||||||
const char *username = block.GetBlockValue("username");
|
const char *username = block.GetBlockValue("username");
|
||||||
if (username == nullptr)
|
if (username == nullptr)
|
||||||
throw PluginUnavailable("No Tidal username configured");
|
throw PluginUnconfigured("No Tidal username configured");
|
||||||
|
|
||||||
const char *password = block.GetBlockValue("password");
|
const char *password = block.GetBlockValue("password");
|
||||||
if (password == nullptr)
|
if (password == nullptr)
|
||||||
throw PluginUnavailable("No Tidal password configured");
|
throw PluginUnconfigured("No Tidal password configured");
|
||||||
|
|
||||||
tidal_audioquality = block.GetBlockValue("audioquality", "HIGH");
|
tidal_audioquality = block.GetBlockValue("audioquality", "HIGH");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user