[Chore]Common Logger: Log missing Exception type (#35084)

log type for exception and inner exception
This commit is contained in:
Davide Giacometti 2024-10-18 11:11:18 +02:00 committed by GitHub
parent 195c6f588a
commit 2ef987e1d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,14 +60,29 @@ namespace ManagedCommon
public static void LogError(string message, Exception ex)
{
Log(
message + Environment.NewLine +
ex?.Message + Environment.NewLine +
"Inner exception: " + Environment.NewLine +
ex?.InnerException?.Message + Environment.NewLine +
"Stack trace: " + Environment.NewLine +
ex?.StackTrace,
Error);
if (ex == null)
{
LogError(message);
}
else
{
var exMessage =
message + Environment.NewLine +
ex.GetType() + ": " + ex.Message + Environment.NewLine;
if (ex.InnerException != null)
{
exMessage +=
"Inner exception: " + Environment.NewLine +
ex.InnerException.GetType() + ": " + ex.InnerException.Message + Environment.NewLine;
}
exMessage +=
"Stack trace: " + Environment.NewLine +
ex.StackTrace;
Log(exMessage, Error);
}
}
public static void LogWarning(string message)