mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Better error formatting
This commit is contained in:
@@ -47,20 +47,25 @@ public class CompileCommand : Command<CompileCommand.Settings>
|
|||||||
var l = error.Line;
|
var l = error.Line;
|
||||||
var c = error.Column;
|
var c = error.Column;
|
||||||
var msg = error.Message;
|
var msg = error.Message;
|
||||||
var ctx = error.Context ?? "";
|
var ctx = error.Context;
|
||||||
|
|
||||||
var diagnostic = error.Warning
|
var diagnostic = error.Warning
|
||||||
? Diagnostic.Warning(msg)
|
? Diagnostic.Warning(msg)
|
||||||
: Diagnostic.Error(msg);
|
: Diagnostic.Error(msg);
|
||||||
|
|
||||||
if (ctx is not null && error.Line >= 0 && error.Column >= 0)
|
if (ctx is not null)
|
||||||
{
|
{
|
||||||
Label label = new(ctx, new Location(l, c), "")
|
if (error.Line >= 0 && error.Column >= 0)
|
||||||
{
|
{
|
||||||
Color = error.Warning ? Color.Yellow : Color.Red
|
var label = new Label(ctx, new Location(l, c), "")
|
||||||
};
|
.WithColor(error.Warning ? Color.Yellow : Color.Red);
|
||||||
|
|
||||||
diagnostic = diagnostic.WithLabel(label);
|
diagnostic.Labels.Add(label);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
diagnostic.Note = ctx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
report.AddDiagnostic(diagnostic);
|
report.AddDiagnostic(diagnostic);
|
||||||
@@ -79,6 +84,8 @@ public class CompileCommand : Command<CompileCommand.Settings>
|
|||||||
var success = MarkupCompiler.Compile(compilands, dataTableInput);
|
var success = MarkupCompiler.Compile(compilands, dataTableInput);
|
||||||
|
|
||||||
report.Render(AnsiConsole.Console);
|
report.Render(AnsiConsole.Console);
|
||||||
|
AnsiConsole.WriteLine();
|
||||||
|
AnsiConsole.WriteLine();
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user