2016-05-17 01:50:02 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
2017-01-18 09:12:22 +01:00
|
|
|
|
namespace Teknik.Utilities
|
2016-05-17 01:50:02 +02:00
|
|
|
|
{
|
|
|
|
|
public static class ExceptionExtensions
|
|
|
|
|
{
|
2017-01-18 09:12:22 +01:00
|
|
|
|
public static string GetFullMessage(this Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return ex.GetFullMessage(false, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetFullMessage(this Exception ex, bool recursive)
|
|
|
|
|
{
|
|
|
|
|
return ex.GetFullMessage(recursive, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetFullMessage(this Exception ex, bool recursive, bool stackTrace)
|
2016-05-17 01:50:02 +02:00
|
|
|
|
{
|
|
|
|
|
string message = ex.Message;
|
|
|
|
|
if (recursive && ex.InnerException != null)
|
|
|
|
|
{
|
|
|
|
|
message += " | Inner Exception: " + ex.InnerException.GetFullMessage(recursive, stackTrace);
|
|
|
|
|
}
|
|
|
|
|
if (stackTrace && !string.IsNullOrEmpty(ex.StackTrace))
|
|
|
|
|
{
|
|
|
|
|
message += " | Stack Trace: " + ex.StackTrace;
|
|
|
|
|
}
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|