Hi,
Tonight a useful Exception Extension Method in order to Get Full Stack Trace With Inner Exception Recursion.
public static class ExceptionExtensions
{
public static String ToFullStackTrace(this Exception ex, Int32 count)
{
if (ex == null)
throw new ArgumentException();
StringBuilder sb = new StringBuilder();
sb.Append(ex.StackTrace);
int innerReferences = 0;
Exception inner = ex.InnerException;
while (inner != null && innerReferences < count)
{
sb.Insert(0, inner.StackTrace);
inner = inner.InnerException;
innerReferences++;
}
return sb.ToString();
}
public static String ToFullStackTrace(this Exception ex)
{
return ex.ToFullStackTrace(50);
}
}
Hope this Help’s!
Views(1811)

