summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-09-05 11:29:10 +0200
committerMax Kellermann <max@musicpd.org>2016-09-05 11:31:23 +0200
commita69c3c1848ec324975faa0dd14f0e7750c46bfee (patch)
tree213903d1488750ad0c6d39b15c829b0653221b73
parent50e5244e2511636fc031e20029d4aa3c47bb9658 (diff)
neighbor/Glue: support C++ exceptions
-rw-r--r--src/neighbor/Glue.cxx23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/neighbor/Glue.cxx b/src/neighbor/Glue.cxx
index 3cf7518f9..3953dfb25 100644
--- a/src/neighbor/Glue.cxx
+++ b/src/neighbor/Glue.cxx
@@ -27,6 +27,9 @@
#include "config/ConfigError.hxx"
#include "config/Block.hxx"
#include "util/Error.hxx"
+#include "util/RuntimeError.hxx"
+
+#include <stdexcept>
NeighborGlue::Explorer::~Explorer()
{
@@ -61,14 +64,20 @@ NeighborGlue::Init(EventLoop &loop, NeighborListener &listener, Error &error)
{
for (const auto *block = config_get_block(ConfigBlockOption::NEIGHBORS);
block != nullptr; block = block->next) {
- NeighborExplorer *explorer =
- CreateNeighborExplorer(loop, listener, *block, error);
- if (explorer == nullptr) {
- error.FormatPrefix("Line %i: ", block->line);
- return false;
+ try {
+ auto *explorer =
+ CreateNeighborExplorer(loop, listener, *block,
+ error);
+ if (explorer == nullptr) {
+ error.FormatPrefix("Line %i: ", block->line);
+ return false;
+ }
+
+ explorers.emplace_front(explorer);
+ } catch (...) {
+ std::throw_with_nested(FormatRuntimeError("Line %i: ",
+ block->line));
}
-
- explorers.emplace_front(explorer);
}
return true;