From ece35552fec977601cfc32a64c04c10a7ea83b3e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 29 May 2019 22:33:51 +0200 Subject: [PATCH] config/Block: add ThrowWithNested() --- src/config/Block.cxx | 7 +++++++ src/config/Block.hxx | 8 ++++++++ 2 files changed, 15 insertions(+) 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 {