private string FormatSpanError(SpanException ex) { return(Formatter switch { LogFormatter.MSBuild => $"{ex.Span.FileName}({ex.Span.StartColonString(',')}) : error BOP{ex.ErrorCode}: {ex.Message}", LogFormatter.Structured => $"[{DateTime.Now}][Compiler][Error] Issue located in '{ex.Span.FileName}' at {ex.Span.StartColonString()}: {ex.Message}", LogFormatter.JSON => $@"{{""Message"": ""{ex.Message.EscapeString()}"", ""Span"": {ex.Span.ToJson()}}}", _ => throw new ArgumentOutOfRangeException() });
/// <summary> /// Format and write a <see cref="SpanException"/> /// </summary> private async Task WriteSpanError(SpanException ex) { var message = Formatter switch { LogFormatter.MSBuild => $"{ex.Span.FileName}({ex.Span.StartColonString(',')}) : error BOP{ex.ErrorCode}: {ex.Message}", LogFormatter.Structured => $"[{DateTime.Now}][Compiler][Error] Issue located in '{ex.Span.FileName}' at {ex.Span.StartColonString()}: {ex.Message}", LogFormatter.JSON => $@"{{""Message"": ""{ex.Message}"", ""Span"": {ex.Span.ToJson()}}}", _ => throw new ArgumentOutOfRangeException() }; await Console.Error.WriteLineAsync(message).ConfigureAwait(false); }
private string FormatSpanError(SpanException ex) => FormatDiagnostic(new(ex.Severity, ex.Message, ex.ErrorCode, ex.Span));