Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log exception when (static) mapping file cannot be read #1202

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}

/// <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