config/Param: overload GetPath() throwing exception
This commit is contained in:
		| @@ -23,6 +23,8 @@ | ||||
| #include "fs/AllocatedPath.hxx" | ||||
| #include "util/Error.hxx" | ||||
|  | ||||
| #include <stdexcept> | ||||
|  | ||||
| ConfigParam::ConfigParam(const char *_value, int _line) | ||||
| 	:next(nullptr), value(_value), line(_line), used(false) {} | ||||
|  | ||||
| @@ -41,3 +43,15 @@ ConfigParam::GetPath(Error &error) const | ||||
| 	return path; | ||||
|  | ||||
| } | ||||
|  | ||||
| AllocatedPath | ||||
| ConfigParam::GetPath() const | ||||
| { | ||||
| 	Error error; | ||||
| 	auto path = ParsePath(value.c_str(), error); | ||||
| 	if (gcc_unlikely(path.IsNull())) | ||||
| 		throw std::runtime_error(error.GetMessage()); | ||||
|  | ||||
| 	return path; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -72,6 +72,15 @@ struct ConfigParam { | ||||
| 	 * AllocatedPath::Null() and sets the error. | ||||
| 	 */ | ||||
| 	AllocatedPath GetPath(Error &error) const; | ||||
|  | ||||
| 	/** | ||||
| 	 * Parse the value as a path.  If there is a tilde prefix, it | ||||
| 	 * is expanded. | ||||
| 	 * | ||||
| 	 * Throws #std::runtime_error on error. | ||||
| 	 */ | ||||
| 	gcc_pure | ||||
| 	AllocatedPath GetPath() const; | ||||
| }; | ||||
|  | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann