neighbor/Glue: mention failed plugin name in error message
This commit is contained in:
parent
070c03dbf7
commit
a8087dc12c
2
NEWS
2
NEWS
|
@ -1,4 +1,6 @@
|
||||||
ver 0.23.2 (not yet released)
|
ver 0.23.2 (not yet released)
|
||||||
|
* neighbor
|
||||||
|
- mention failed plugin name in error message
|
||||||
|
|
||||||
ver 0.23.1 (2021/10/19)
|
ver 0.23.1 (2021/10/19)
|
||||||
* protocol
|
* protocol
|
||||||
|
|
|
@ -33,12 +33,9 @@ NeighborGlue::~NeighborGlue() noexcept = default;
|
||||||
|
|
||||||
static std::unique_ptr<NeighborExplorer>
|
static std::unique_ptr<NeighborExplorer>
|
||||||
CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener,
|
CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener,
|
||||||
|
const char *plugin_name,
|
||||||
const ConfigBlock &block)
|
const ConfigBlock &block)
|
||||||
{
|
{
|
||||||
const char *plugin_name = block.GetBlockValue("plugin");
|
|
||||||
if (plugin_name == nullptr)
|
|
||||||
throw std::runtime_error("Missing \"plugin\" configuration");
|
|
||||||
|
|
||||||
const NeighborPlugin *plugin = GetNeighborPluginByName(plugin_name);
|
const NeighborPlugin *plugin = GetNeighborPluginByName(plugin_name);
|
||||||
if (plugin == nullptr)
|
if (plugin == nullptr)
|
||||||
throw FormatRuntimeError("No such neighbor plugin: %s",
|
throw FormatRuntimeError("No such neighbor plugin: %s",
|
||||||
|
@ -55,8 +52,14 @@ NeighborGlue::Init(const ConfigData &config,
|
||||||
block.SetUsed();
|
block.SetUsed();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
explorers.emplace_front(CreateNeighborExplorer(loop,
|
const char *plugin_name = block.GetBlockValue("plugin");
|
||||||
|
if (plugin_name == nullptr)
|
||||||
|
throw std::runtime_error("Missing \"plugin\" configuration");
|
||||||
|
|
||||||
|
explorers.emplace_front(plugin_name,
|
||||||
|
CreateNeighborExplorer(loop,
|
||||||
listener,
|
listener,
|
||||||
|
plugin_name,
|
||||||
block));
|
block));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
std::throw_with_nested(FormatRuntimeError("Line %i: ",
|
std::throw_with_nested(FormatRuntimeError("Line %i: ",
|
||||||
|
@ -76,6 +79,9 @@ NeighborGlue::Open()
|
||||||
/* roll back */
|
/* roll back */
|
||||||
for (auto k = explorers.begin(); k != i; ++k)
|
for (auto k = explorers.begin(); k != i; ++k)
|
||||||
k->explorer->Close();
|
k->explorer->Close();
|
||||||
|
|
||||||
|
std::throw_with_nested(FormatRuntimeError("Failed to open neighblor plugin '%s'",
|
||||||
|
i->name.c_str()));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct ConfigData;
|
struct ConfigData;
|
||||||
class EventLoop;
|
class EventLoop;
|
||||||
|
@ -36,11 +37,13 @@ struct NeighborInfo;
|
||||||
*/
|
*/
|
||||||
class NeighborGlue {
|
class NeighborGlue {
|
||||||
struct Explorer {
|
struct Explorer {
|
||||||
|
const std::string name;
|
||||||
std::unique_ptr<NeighborExplorer> explorer;
|
std::unique_ptr<NeighborExplorer> explorer;
|
||||||
|
|
||||||
template<typename E>
|
template<typename N, typename E>
|
||||||
Explorer(E &&_explorer) noexcept
|
Explorer(N &&_name, E &&_explorer) noexcept
|
||||||
:explorer(std::forward<E>(_explorer)) {}
|
:name(std::forward<N>(_name)),
|
||||||
|
explorer(std::forward<E>(_explorer)) {}
|
||||||
|
|
||||||
Explorer(const Explorer &) = delete;
|
Explorer(const Explorer &) = delete;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue