Commit b86d8d0c authored by Max Kellermann's avatar Max Kellermann

config/Param: add method ThrowWithNested()

parent 0b4e7b33
...@@ -24,13 +24,19 @@ ...@@ -24,13 +24,19 @@
#include <stdexcept> #include <stdexcept>
void
ConfigParam::ThrowWithNested() const
{
std::throw_with_nested(FormatRuntimeError("Error on line %i", line));
}
AllocatedPath AllocatedPath
ConfigParam::GetPath() const ConfigParam::GetPath() const
{ {
try { try {
return ParsePath(value.c_str()); return ParsePath(value.c_str());
} catch (...) { } catch (...) {
std::throw_with_nested(FormatRuntimeError("Invalid path at line %i: ", line)); ThrowWithNested();
} }
} }
...@@ -58,6 +58,14 @@ struct ConfigParam { ...@@ -58,6 +58,14 @@ struct ConfigParam {
* Throws #std::runtime_error on error. * Throws #std::runtime_error on error.
*/ */
AllocatedPath GetPath() const; 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 #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