Output searched locations on import failure.

This commit is contained in:
joshuatarkwski
2022-02-08 16:20:27 +01:00
committed by chriseth
parent 6b8654384c
commit 6225dad332
3 changed files with 22 additions and 11 deletions
@@ -3,8 +3,8 @@
[
{
"component": "general",
"formattedMessage": "Cannot import url (\"in.yul\"): File not found.",
"message": "Cannot import url (\"in.yul\"): File not found.",
"formattedMessage": "Cannot import url (\"in.yul\"): File not found. Searched the following locations: \"\".",
"message": "Cannot import url (\"in.yul\"): File not found. Searched the following locations: \"\".",
"severity": "error",
"type": "IOError"
},
+3 -3
View File
@@ -100,7 +100,7 @@ ImportCheck checkImport(
return ImportCheck::OK();
static regex const sourceNotFoundErrorRegex{
R"(^Error \(6275\): Source ".+" not found: (.*)\.\n)"
R"(^Error \(6275\): Source "[^"]+" not found: (.*)\.\n)"
R"(\s*--> .*<stdin>:\d+:\d+:\n)"
R"(\s*\|\n)"
R"(\d+\s*\| import '.+';\n)"
@@ -110,12 +110,12 @@ ImportCheck checkImport(
smatch submatches;
if (!regex_match(cliResult.stderrContent, submatches, sourceNotFoundErrorRegex))
return ImportCheck::Unknown("Unexpected stderr content: '" + cliResult.stderrContent + "'");
if (submatches[1] != "File not found" && submatches[1] != "File outside of allowed directories")
if (submatches[1] != "File not found" && !boost::starts_with(string(submatches[1]), "File outside of allowed directories"))
return ImportCheck::Unknown("Unexpected error message: '" + cliResult.stderrContent + "'");
if (submatches[1] == "File not found")
return ImportCheck::FileNotFound();
else if (submatches[1] == "File outside of allowed directories")
else if (boost::starts_with(string(submatches[1]), "File outside of allowed directories"))
return ImportCheck::PathDisallowed();
else
return ImportCheck::Unknown("Unexpected error message '" + submatches[1].str() + "'");