Skip to content

Commit

Permalink
Log exception when (static) mapping file cannot be read
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH authored Oct 29, 2024
1 parent 214fb53 commit e29fd37
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)

Check warning on line 55 in src/WireMock.Net/Logging/WireMockConsoleLogger.cs

View check run for this annotation

Codecov / codecov/patch

src/WireMock.Net/Logging/WireMockConsoleLogger.cs#L55

Added line #L55 was not covered by tests
{
Console.WriteLine(Format("Error", formatString, exception.Message));
Console.WriteLine(Format("Error", $"{message} {{0}}", exception.Message));

Check warning on line 57 in src/WireMock.Net/Logging/WireMockConsoleLogger.cs

View check run for this annotation

Codecov / codecov/patch

src/WireMock.Net/Logging/WireMockConsoleLogger.cs#L57

Added line #L57 was not covered by tests

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 e29fd37

Please sign in to comment.