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