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.
24 lines
671 B
24 lines
671 B
using System;
|
|
|
|
namespace Infrastructure.Extensions
|
|
{
|
|
public static class ExceptionExtensions
|
|
{
|
|
public static void PrintStack(this Exception ex, string message = null)
|
|
{
|
|
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
|
|
if (message != null)
|
|
{
|
|
Console.WriteLine(message);
|
|
}
|
|
Console.WriteLine(ex.Message);
|
|
Console.WriteLine(ex.StackTrace);
|
|
ex.InnerException?.PrintStack();
|
|
}
|
|
|
|
public static string GetMessage(this Exception ex)
|
|
{
|
|
return ex.InnerException?.Message ?? ex.Message;
|
|
}
|
|
}
|
|
} |