config/Param: add method ThrowWithNested()
This commit is contained in:
parent
0b4e7b3317
commit
b86d8d0cd8
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue