Skip to content

Commit

Permalink
Log exception when (static) mapping file cannot be read (#1202)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH authored Oct 29, 2024
1 parent 214fb53 commit 3693d6a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/WireMock.Net.Abstractions/Logging/IWireMockLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public interface IWireMockLogger
/// <summary>
/// Writes the message at the Error level using the specified exception.
/// </summary>
/// <param name="formatString">The format string.</param>
/// <param name="message">The message.</param>
/// <param name="exception">The exception.</param>
[PublicAPI]
void Error(string formatString, Exception exception);
void Error(string message, Exception exception);

/// <summary>
/// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more).
Expand Down
4 changes: 2 additions & 2 deletions src/WireMock.Net/Logging/WireMockConsoleLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public void Error(string formatString, params object[] args)
}

/// <see cref="IWireMockLogger.Error(string, Exception)"/>
public void Error(string formatString, Exception exception)
public void Error(string message, Exception exception)
{
Console.WriteLine(Format("Error", formatString, exception.Message));
Console.WriteLine(Format("Error", $"{message} {{0}}", exception.Message));

if (exception is AggregateException ae)
{
Expand Down
2 changes: 1 addition & 1 deletion src/WireMock.Net/Logging/WireMockNullLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Error(string formatString, params object[] args)
}

/// <see cref="IWireMockLogger.Error(string, Exception)"/>
public void Error(string formatString, Exception exception)
public void Error(string message, Exception exception)
{
// Log nothing
}
Expand Down
4 changes: 2 additions & 2 deletions src/WireMock.Net/Server/WireMockServer.Admin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ public void ReadStaticMappings(string? folder = null)
{
ReadStaticMappingAndAddOrUpdate(filename);
}
catch
catch (Exception exception)
{
_settings.Logger.Error("Static MappingFile : '{0}' could not be read. This file will be skipped.", filename);
_settings.Logger.Error($"Static MappingFile : '{filename}' could not be read. This file will be skipped.", exception);
}
}
}
Expand Down

0 comments on commit 3693d6a

Please sign in to comment.