From 5b13b57fe600724344c556fe4309a5d6bb3d39ab Mon Sep 17 00:00:00 2001 From: Kai Yao Date: Thu, 7 Oct 2021 23:38:50 -0700 Subject: Return diagnostics data when encountering module load error by exception (#1966) --- source/slang/slang.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 6fe778435..996b539ee 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -825,11 +825,11 @@ SLANG_NO_THROW slang::IModule* SLANG_MCALL Linkage::loadModule( const char* moduleName, slang::IBlob** outDiagnostics) { + DiagnosticSink sink(getSourceManager(), Lexer::sourceLocationLexer); try { auto name = getNamePool()->getName(moduleName); - DiagnosticSink sink(getSourceManager(), Lexer::sourceLocationLexer); auto module = findOrImportModule(name, SourceLoc(), &sink); sink.getBlobIfNeeded(outDiagnostics); @@ -838,6 +838,7 @@ SLANG_NO_THROW slang::IModule* SLANG_MCALL Linkage::loadModule( } catch (const AbortCompilationException&) { + sink.getBlobIfNeeded(outDiagnostics); return nullptr; } } -- cgit v1.2.3