未验证 提交 33628769 编写于 作者: H Heejae Chang 提交者: GitHub

made service hub to log more detail info on certain exception (#24676)

上级 0e01a3d5
......@@ -3,6 +3,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Execution;
......@@ -254,11 +255,47 @@ private bool LogUnlessCanceled(Exception ex, CancellationToken cancellationToken
{
LogError("Exception: " + ex.ToString());
LogExtraInformation(ex);
var callStack = new StackTrace().ToString();
LogError("From: " + callStack);
}
return false;
}
private void LogExtraInformation(Exception ex)
{
if (ex == null)
{
return;
}
if (ex is ReflectionTypeLoadException reflection)
{
foreach (var loaderException in reflection.LoaderExceptions)
{
LogError("LoaderException: " + loaderException.ToString());
LogExtraInformation(loaderException);
}
}
if (ex is FileNotFoundException file)
{
LogError("FusionLog: " + file.FusionLog);
}
if (ex is AggregateException agg)
{
foreach (var innerException in agg.InnerExceptions)
{
LogExtraInformation(innerException);
}
}
else
{
LogExtraInformation(ex.InnerException);
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册