pattern: Improved error messages when including std files or calling unknown std functions
This commit is contained in:
parent
8ab4d25e33
commit
5c3bfa690b
@ -2015,8 +2015,13 @@ namespace hex::pl {
|
||||
for (auto &func : customFunctions)
|
||||
functions.insert(func);
|
||||
|
||||
if (!functions.contains(this->m_functionName))
|
||||
if (!functions.contains(this->m_functionName)) {
|
||||
if (this->m_functionName.starts_with("std::")) {
|
||||
evaluator->getConsole().log(LogConsole::Level::Warning, "This function might be part of the standard library.\nYou can install the standard library though\nthe Content Store found under Help -> Content Store.");
|
||||
}
|
||||
|
||||
LogConsole::abortEvaluation(hex::format("call to unknown function '{}'", this->m_functionName), this);
|
||||
}
|
||||
|
||||
auto function = functions[this->m_functionName];
|
||||
if (function.parameterCount == ContentRegistry::PatternLanguage::UnlimitedParameters) {
|
||||
|
@ -72,8 +72,12 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
File file(includePath, File::Mode::Read);
|
||||
if (!file.isValid())
|
||||
throwPreprocessorError(hex::format("{0}: No such file or directory", includeFile.c_str()), lineNumber);
|
||||
if (!file.isValid()) {
|
||||
if (includePath.parent_path().filename().string() == "std")
|
||||
throwPreprocessorError(hex::format("{0}: No such file or directory.\n\nThis file might be part of the standard library.\nYou can install the standard library though\nthe Content Store found under Help -> Content Store.", includeFile.c_str()), lineNumber);
|
||||
else
|
||||
throwPreprocessorError(hex::format("{0}: No such file or directory", includeFile.c_str()), lineNumber);
|
||||
}
|
||||
|
||||
bool shouldInclude = true;
|
||||
this->addPragmaHandler("once", [&, includePath, this](const std::string &value) {
|
||||
|
Loading…
Reference in New Issue
Block a user