code/KustoCopyConsole/ErrorHelper.cs (21 lines of code) (raw):
using System.Diagnostics;
namespace KustoCopyConsole
{
internal static class ErrorHelper
{
public static void DisplayException(Exception ex)
{
DisplayExceptionInternal(ex);
}
private static void DisplayExceptionInternal(Exception ex, string tab = "")
{
Trace.TraceError(
$"{tab}Exception encountered: {ex.GetType().FullName} ; {ex.Message}");
Trace.TraceError($"{tab}Stack trace: {ex.StackTrace}");
if (ex.InnerException != null)
{
DisplayExceptionInternal(ex.InnerException, tab + " ");
}
}
}
}