Show file name in error messages, to handle errors from modules easier
This commit is contained in:
@@ -8,15 +8,17 @@ namespace Upsilon
|
||||
{
|
||||
public class Diagnostics
|
||||
{
|
||||
public string FileName { get; }
|
||||
public SourceText ScriptString { get; }
|
||||
public readonly List<DiagnosticsMessage> Errors = new List<DiagnosticsMessage>();
|
||||
public readonly List<DiagnosticsMessage> Warnings = new List<DiagnosticsMessage>();
|
||||
public bool ThrowsOnError { get; }
|
||||
|
||||
public Diagnostics(SourceText scriptString, bool throwsOnError)
|
||||
public Diagnostics(SourceText scriptString, bool throwsOnError, string fileName)
|
||||
{
|
||||
ScriptString = scriptString;
|
||||
ThrowsOnError = throwsOnError;
|
||||
FileName = fileName;
|
||||
}
|
||||
|
||||
public void Log(DiagnosticLevel level, string message, TextSpan location)
|
||||
@@ -33,7 +35,7 @@ namespace Upsilon
|
||||
{
|
||||
var linePos = ScriptString.GetLinePosition(location.Start);
|
||||
var line = ScriptString.GetLine(linePos.Line);
|
||||
throw new ParseException(message, linePos.Line, linePos.Pos, line);
|
||||
throw new ParseException(FileName, message, linePos.Line, linePos.Pos, line);
|
||||
}
|
||||
Log(DiagnosticLevel.Error, message, location);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user