mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Log model errors even in standalone extraction
This commit is contained in:
@@ -376,6 +376,19 @@ namespace Semmle.Extraction
|
||||
Extractor.Message(msg);
|
||||
}
|
||||
|
||||
private void ExtractionError(InternalError error)
|
||||
{
|
||||
ExtractionError(new Message(error.Message, error.EntityText, CreateLocation(error.Location), error.StackTrace, Severity.Error));
|
||||
}
|
||||
|
||||
private void ReportError(InternalError error)
|
||||
{
|
||||
if (!Extractor.Standalone)
|
||||
throw error;
|
||||
|
||||
ExtractionError(error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signal an error in the program model.
|
||||
/// </summary>
|
||||
@@ -383,8 +396,7 @@ namespace Semmle.Extraction
|
||||
/// <param name="msg">The error message.</param>
|
||||
public void ModelError(SyntaxNode node, string msg)
|
||||
{
|
||||
if (!Extractor.Standalone)
|
||||
throw new InternalError(node, msg);
|
||||
ReportError(new InternalError(node, msg));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -394,8 +406,7 @@ namespace Semmle.Extraction
|
||||
/// <param name="msg">The error message.</param>
|
||||
public void ModelError(ISymbol symbol, string msg)
|
||||
{
|
||||
if (!Extractor.Standalone)
|
||||
throw new InternalError(symbol, msg);
|
||||
ReportError(new InternalError(symbol, msg));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -404,8 +415,7 @@ namespace Semmle.Extraction
|
||||
/// <param name="msg">The error message.</param>
|
||||
public void ModelError(string msg)
|
||||
{
|
||||
if (!Extractor.Standalone)
|
||||
throw new InternalError(msg);
|
||||
ReportError(new InternalError(msg));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,8 +11,13 @@
|
||||
import csharp
|
||||
import semmle.code.csharp.commons.Diagnostics
|
||||
|
||||
private string getLocation(ExtractorError error) {
|
||||
if error.getLocation().getFile().fromSource()
|
||||
then result = " in " + error.getLocation().getFile()
|
||||
else result = ""
|
||||
}
|
||||
|
||||
from ExtractorError error
|
||||
where not exists(CompilerError ce | ce.getLocation().getFile() = error.getLocation().getFile())
|
||||
select error,
|
||||
"Unexpected " + error.getOrigin() + " error: " + error.getText() + " in " +
|
||||
error.getLocation().getFile(), 3
|
||||
"Unexpected " + error.getOrigin() + " error" + getLocation(error) + ": " + error.getText(), 3
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
| Program.cs:9:32:9:46 | Unable to resolve target for call. (Compilation error?) | Unexpected C# extractor error in Program.cs: Unable to resolve target for call. (Compilation error?) | 3 |
|
||||
| file://:0:0:0:0 | Unhandled literal type | Unexpected C# extractor error: Unhandled literal type | 3 |
|
||||
|
||||
Reference in New Issue
Block a user