diff --git a/src/Elastic.Documentation/Diagnostics/DiagnosticsCollector.cs b/src/Elastic.Documentation/Diagnostics/DiagnosticsCollector.cs index 5207c58c6..ec3fc38f3 100644 --- a/src/Elastic.Documentation/Diagnostics/DiagnosticsCollector.cs +++ b/src/Elastic.Documentation/Diagnostics/DiagnosticsCollector.cs @@ -111,6 +111,8 @@ public void Emit(Severity severity, string file, string message) => Message = message }); + public void EmitError(string file, string message, string specificErrorMessage) => Emit(Severity.Error, file, $"{message}{Environment.NewLine}{specificErrorMessage}"); + public void EmitError(string file, string message, Exception? e = null) { message = message diff --git a/src/Elastic.Documentation/Diagnostics/IDiagnosticsCollector.cs b/src/Elastic.Documentation/Diagnostics/IDiagnosticsCollector.cs index 6e2c2c361..6e804ad76 100644 --- a/src/Elastic.Documentation/Diagnostics/IDiagnosticsCollector.cs +++ b/src/Elastic.Documentation/Diagnostics/IDiagnosticsCollector.cs @@ -23,6 +23,7 @@ public interface IDiagnosticsCollector : IAsyncDisposable, IHostedService void Emit(Severity severity, string file, string message); void EmitError(string file, string message, Exception? e = null); + void EmitError(string file, string message, string specificErrorMessage); void EmitWarning(string file, string message); void EmitHint(string file, string message); void Write(Diagnostic diagnostic); diff --git a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs index d3218331f..a6410ffbf 100644 --- a/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs +++ b/src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs @@ -116,7 +116,7 @@ string Resolve(string path) if (Uri.IsWellFormedUriString(path, UriKind.Absolute)) // Cross-repo links { _ = linkResolver.TryResolve( - e => _logger.LogError("An error occurred while resolving cross-link {Path}: {Error}", path, e), + specificErrorMessage => context.Collector.EmitError(path, $"An error occurred while resolving cross-link {path}", specificErrorMessage), new Uri(path), out uri); }