Move nil check into FileDiagnosticsWriter implementation of WriteDiagnostic

This commit is contained in:
Michael B. Gale
2026-01-25 15:33:26 +00:00
parent 8e7d62600d
commit 45e0a929a8

View File

@@ -65,6 +65,10 @@ type FileDiagnosticsWriter struct {
}
func (writer *FileDiagnosticsWriter) WriteDiagnostic(d diagnostic) {
if writer == nil {
return
}
content, err := json.Marshal(d)
if err != nil {
slog.Error("Failed to encode diagnostic as JSON", slog.Any("err", err))
@@ -142,9 +146,6 @@ func emitDiagnosticTo(writer DiagnosticsWriter, sourceid, sourcename, markdownMe
// Emits a diagnostic using the default `DiagnosticsWriter`.
func emitDiagnostic(sourceid, sourcename, markdownMessage string, severity diagnosticSeverity, visibility *visibilityStruct, location *locationStruct) {
if DefaultWriter == nil {
return
}
emitDiagnosticTo(DefaultWriter, sourceid, sourcename, markdownMessage, severity, visibility, location)
}