summaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-05-29 22:33:51 +0200
committerMax Kellermann <max@musicpd.org>2019-05-29 22:33:51 +0200
commitece35552fec977601cfc32a64c04c10a7ea83b3e (patch)
treed1af2821c017c1e8933cb44f241deec4df6c0c35 /src/config
parent7d599c1afc01324fb143a056e4116fc596cb7e42 (diff)
config/Block: add ThrowWithNested()
Diffstat (limited to 'src/config')
-rw-r--r--src/config/Block.cxx7
-rw-r--r--src/config/Block.hxx8
2 files changed, 15 insertions, 0 deletions
diff --git a/src/config/Block.cxx b/src/config/Block.cxx
index 99dafe664..2671d7a11 100644
--- a/src/config/Block.cxx
+++ b/src/config/Block.cxx
@@ -26,6 +26,13 @@
#include <assert.h>
#include <stdlib.h>
+void
+BlockParam::ThrowWithNested() const
+{
+ std::throw_with_nested(FormatRuntimeError("Error in setting \"%s\" on line %i",
+ name.c_str(), line));
+}
+
int
BlockParam::GetIntValue() const
{
diff --git a/src/config/Block.hxx b/src/config/Block.hxx
index 8d58e6fb3..0a038c838 100644
--- a/src/config/Block.hxx
+++ b/src/config/Block.hxx
@@ -51,6 +51,14 @@ struct BlockParam {
unsigned GetPositiveValue() const;
bool GetBoolValue() const;
+
+ /**
+ * Call this method in a "catch" block to throw a nested
+ * exception showing the location of this setting in the
+ * configuration file.
+ */
+ [[noreturn]]
+ void ThrowWithNested() const;
};
struct ConfigBlock {