You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
796 B
26 lines
796 B
using System;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace Infrastructure.Extensions
|
|
{
|
|
public static class ExceptionExtensions
|
|
{
|
|
public static void PrintStack(this Exception ex, string message = null, [CallerMemberName] string memberName = "")
|
|
{
|
|
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
|
|
if (message != null)
|
|
{
|
|
Console.WriteLine(message);
|
|
}
|
|
Console.WriteLine(memberName);
|
|
Console.WriteLine(ex.Message);
|
|
Console.WriteLine(ex.StackTrace);
|
|
ex.InnerException?.PrintStack();
|
|
}
|
|
|
|
public static string GetMessage(this Exception ex)
|
|
{
|
|
return ex.InnerException?.Message ?? ex.Message;
|
|
}
|
|
}
|
|
} |