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 eb7cf46c95.

* Fix loggers with improved exception logging.
This commit is contained in:
JvE-iO
2025-01-30 10:59:22 +01:00
committed by GitHub
parent 52b00d74a9
commit 29bf9b42f8
3 changed files with 7 additions and 7 deletions

View File

@@ -52,9 +52,9 @@ public class WireMockService : IWireMockService
_logger.LogDebug("Admin[{0}] {1}", isAdminrequest, message);
}
public void Error(string formatString, Exception exception)
public void Error(string message, Exception exception)
{
_logger.LogError(formatString, exception.Message);
_logger.LogError(exception, message);
}
}

View File

@@ -51,9 +51,9 @@ public sealed class TUnitWireMockLogger : IWireMockLogger
}
/// <inheritdoc />
public void Error(string formatString, Exception exception)
public void Error(string message, Exception exception)
{
_tUnitLogger.LogError(Format("Error", formatString, exception.Message), exception);
_tUnitLogger.LogError(Format("Error", $"{message} {{0}}", exception));
if (exception is AggregateException ae)
{

View File

@@ -50,15 +50,15 @@ public sealed class TestOutputHelperWireMockLogger : IWireMockLogger
}
/// <inheritdoc />
public void Error(string formatString, Exception exception)
public void Error(string message, Exception exception)
{
_testOutputHelper.WriteLine(Format("Error", formatString, exception.Message));
_testOutputHelper.WriteLine(Format("Error", $"{message} {{0}}", exception));
if (exception is AggregateException ae)
{
ae.Handle(ex =>
{
_testOutputHelper.WriteLine(Format("Error", "Exception {0}", ex.Message));
_testOutputHelper.WriteLine(Format("Error", "Exception {0}", ex));
return true;
});
}