Skip to content

Commit e29fd37

Browse files
authored
Log exception when (static) mapping file cannot be read
1 parent 214fb53 commit e29fd37

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/WireMock.Net.Abstractions/Logging/IWireMockLogger.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public interface IWireMockLogger
5151
/// <summary>
5252
/// Writes the message at the Error level using the specified exception.
5353
/// </summary>
54-
/// <param name="formatString">The format string.</param>
54+
/// <param name="message">The message.</param>
5555
/// <param name="exception">The exception.</param>
5656
[PublicAPI]
57-
void Error(string formatString, Exception exception);
57+
void Error(string message, Exception exception);
5858

5959
/// <summary>
6060
/// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more).

src/WireMock.Net/Logging/WireMockConsoleLogger.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public void Error(string formatString, params object[] args)
5252
}
5353

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

5959
if (exception is AggregateException ae)
6060
{

src/WireMock.Net/Logging/WireMockNullLogger.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void Error(string formatString, params object[] args)
3636
}
3737

3838
/// <see cref="IWireMockLogger.Error(string, Exception)"/>
39-
public void Error(string formatString, Exception exception)
39+
public void Error(string message, Exception exception)
4040
{
4141
// Log nothing
4242
}

src/WireMock.Net/Server/WireMockServer.Admin.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ public void ReadStaticMappings(string? folder = null)
178178
{
179179
ReadStaticMappingAndAddOrUpdate(filename);
180180
}
181-
catch
181+
catch (Exception exception)
182182
{
183-
_settings.Logger.Error("Static MappingFile : '{0}' could not be read. This file will be skipped.", filename);
183+
_settings.Logger.Error($"Static MappingFile : '{filename}' could not be read. This file will be skipped.", exception);
184184
}
185185
}
186186
}

0 commit comments

Comments
 (0)