CommonIO: Make readFile() check if the file is not a directory and if not fail with a sensible exception rather than std::length_error

This commit is contained in:
Kamil Śliwak
2021-06-25 16:04:58 +02:00
parent cbf1c3ae69
commit 65e23ff171
6 changed files with 29 additions and 0 deletions
+9
View File
@@ -668,6 +668,10 @@ bool CommandLineInterface::parseLibraryOption(string const& _input)
{
// Should not happen if `fs::is_regular_file` is correct.
}
catch (NotAFile const&)
{
// Should not happen if `fs::is_regular_file` is correct.
}
vector<string> libraries;
boost::split(libraries, data, boost::is_space() || boost::is_any_of(","), boost::token_compress_on);
@@ -1263,6 +1267,11 @@ bool CommandLineInterface::processInput()
serr() << "File not found: " << jsonFile << endl;
return false;
}
catch (NotAFile const&)
{
serr() << "Not a regular file: " << jsonFile << endl;
return false;
}
}
StandardCompiler compiler(m_fileReader.reader());
sout() << compiler.compile(std::move(input)) << endl;