diff --git a/src/config/Block.hxx b/src/config/Block.hxx index 0a038c838..b052bb7eb 100644 --- a/src/config/Block.hxx +++ b/src/config/Block.hxx @@ -59,6 +59,19 @@ struct BlockParam { */ [[noreturn]] void ThrowWithNested() const; + + /** + * Invoke a function with the configured value; if the + * function throws, call ThrowWithNested(). + */ + template + auto With(F &&f) const { + try { + return f(value.c_str()); + } catch (...) { + ThrowWithNested(); + } + } }; struct ConfigBlock {