Commit b86d8d0c authored by Max Kellermann's avatar Max Kellermann

config/Param: add method ThrowWithNested()

parent 0b4e7b33
......@@ -24,13 +24,19 @@
#include <stdexcept>
void
ConfigParam::ThrowWithNested() const
{
std::throw_with_nested(FormatRuntimeError("Error on line %i", line));
}
AllocatedPath
ConfigParam::GetPath() const
{
try {
return ParsePath(value.c_str());
} catch (...) {
std::throw_with_nested(FormatRuntimeError("Invalid path at line %i: ", line));
ThrowWithNested();
}
}
......@@ -58,6 +58,14 @@ struct ConfigParam {
* Throws #std::runtime_error on error.
*/
AllocatedPath GetPath() 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;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment