Error messages complete

This commit is contained in:
nub31
2025-05-25 01:27:11 +02:00
parent fac2c95d05
commit e2b868c442
3 changed files with 106 additions and 79 deletions

View File

@@ -569,9 +569,10 @@ public class Parser
if (!Peek().TryGetValue(out var token))
{
throw new ParseException(Diagnostic.Error("Unexpected end of file while parsing type")
.At(_tokens.Last().SourceFile, SourceLocationCalculator.GetSpan(_tokens.Last()))
throw new ParseException(Diagnostic
.Error("Unexpected end of file while parsing type")
.WithHelp("Expected a type name")
.At(_tokens.Last().SourceFile, SourceLocationCalculator.GetSpan(_tokens.Last()))
.Build());
}
@@ -586,9 +587,10 @@ public class Parser
{
if (!Peek().TryGetValue(out var token))
{
throw new ParseException(Diagnostic.Error("Unexpected end of file")
.At(_tokens.Last().SourceFile, SourceLocationCalculator.GetSpan(_tokens.Last()))
throw new ParseException(Diagnostic
.Error("Unexpected end of file")
.WithHelp("Expected more tokens to complete the syntax")
.At(_tokens.Last().SourceFile, SourceLocationCalculator.GetSpan(_tokens.Last()))
.Build());
}
@@ -669,6 +671,7 @@ public class Parser
throw new ParseException(Diagnostic
.Error($"Expected identifier, but found {token.GetType().Name}")
.WithHelp("Provide a valid identifier name here")
.At(token)
.Build());
}