TD-115: Throw error when config file is missing or not readable

TD-49: Log when file management fails

- Thanks to Jelle van der Waa, Ben Boeckel.
This commit is contained in:
Paul Beckingham 2016-03-26 10:35:18 -04:00
parent 152f9b0884
commit 64f87e3c38
3 changed files with 14 additions and 1 deletions

View file

@ -50,7 +50,14 @@ void Rules::load (const std::string& file, int nest /* = 1 */)
if (nest == 1)
{
_settings = defaultSettings;
_original_file = File (file)._data;
File originalFile (file);
_original_file = originalFile._data;
if (! originalFile.exists ())
throw std::string ("ERROR: Configuration file not found.");
if (! originalFile.readable ())
throw std::string ("ERROR: Configuration file cannot be read (insufficient privileges).");
}
// Read the file, then parse the contents.