Skip to content

Commit

Permalink
better throw messages for FindFile
Browse files Browse the repository at this point in the history
  • Loading branch information
PredatorCZ committed Aug 15, 2024
1 parent 864fb73 commit 47ddb65
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/in_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ AppContextFoundStream SimpleIOContext::FindFile(const std::string &rootFolder,
size_t foundIdx = f.find_last_of('/');

if (foundIdx == f.npos) {
throw std::runtime_error("Too many files found.");
throw std::runtime_error("Too many files found for pattern: " +
pattern);
}

if (foundIdx < minFolder) {
Expand All @@ -275,13 +276,14 @@ AppContextFoundStream SimpleIOContext::FindFile(const std::string &rootFolder,
minFolder = foundIdx;
minLevel = clevel;
} else if (clevel == minLevel) {
throw std::runtime_error("Too many files found.");
throw std::runtime_error("Too many files found for pattern: " +
pattern);
}
}
}

if (!winner) {
throw std::runtime_error("Too many files found.");
throw std::runtime_error("Too many files found for pattern: " + pattern);
}

return {OpenFile(*winner), this, AFileInfo(*winner)};
Expand Down

0 comments on commit 47ddb65

Please sign in to comment.