Shader/FilesystemModuleResolver: Don't register in case of parsing errors

This commit is contained in:
SirLynix 2022-03-25 12:56:20 +01:00
parent 83deecd8f1
commit 7af25777dc
1 changed files with 11 additions and 2 deletions

View File

@ -26,9 +26,18 @@ namespace Nz
void FilesystemModuleResolver::RegisterModule(const std::filesystem::path& realPath)
{
ShaderAst::ModulePtr module = ShaderLang::ParseFromFile(realPath);
ShaderAst::ModulePtr module;
try
{
module = ShaderLang::ParseFromFile(realPath);
if (!module)
return;
}
catch (const std::exception& e)
{
NazaraError("failed to register module from file " + realPath.generic_u8string() + ": " + e.what());
return;
}
std::string moduleName = module->metadata->moduleName;
RegisterModule(std::move(module));