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 #include +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 {