Skip to content

Commit 29bf9b4

Browse files
authored
Add exception message to logging when mapping fails due to an exception. (#1248)
* Add exception message to logging when mapping fails due to an exception. * Revert "Add exception message to logging when mapping fails due to an exception." This reverts commit eb7cf46. * Fix loggers with improved exception logging.
1 parent 52b00d7 commit 29bf9b4

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

examples/WireMock.Net.WebApplication.NET6/WireMockService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminreques
5252
_logger.LogDebug("Admin[{0}] {1}", isAdminrequest, message);
5353
}
5454

55-
public void Error(string formatString, Exception exception)
55+
public void Error(string message, Exception exception)
5656
{
57-
_logger.LogError(formatString, exception.Message);
57+
_logger.LogError(exception, message);
5858
}
5959
}
6060

src/WireMock.Net.TUnit/TUnitWireMockLogger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public void Error(string formatString, params object[] args)
5151
}
5252

5353
/// <inheritdoc />
54-
public void Error(string formatString, Exception exception)
54+
public void Error(string message, Exception exception)
5555
{
56-
_tUnitLogger.LogError(Format("Error", formatString, exception.Message), exception);
56+
_tUnitLogger.LogError(Format("Error", $"{message} {{0}}", exception));
5757

5858
if (exception is AggregateException ae)
5959
{

src/WireMock.Net.xUnit/TestOutputHelperWireMockLogger.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ public void Error(string formatString, params object[] args)
5050
}
5151

5252
/// <inheritdoc />
53-
public void Error(string formatString, Exception exception)
53+
public void Error(string message, Exception exception)
5454
{
55-
_testOutputHelper.WriteLine(Format("Error", formatString, exception.Message));
55+
_testOutputHelper.WriteLine(Format("Error", $"{message} {{0}}", exception));
5656

5757
if (exception is AggregateException ae)
5858
{
5959
ae.Handle(ex =>
6060
{
61-
_testOutputHelper.WriteLine(Format("Error", "Exception {0}", ex.Message));
61+
_testOutputHelper.WriteLine(Format("Error", "Exception {0}", ex));
6262
return true;
6363
});
6464
}

0 commit comments

Comments
 (0)