GetMostInner
/// <summary> /// Gets the most inner (deepest) exception of a given Exception object /// </summary> /// <param name="ex">Source Exception</param> /// <returns></returns> public static Exception GetMostInner(this Exception ex) { Exception ActualInnerEx = ex; while (ActualInnerEx != null) { ActualInnerEx = ActualInnerEx.InnerException; if (ActualInnerEx != null) ex = ActualInnerEx; } return ex; }Example:
Exception ex = new Exception("Text1", new Exception("Text2", new Exception("Text3", new Exception("Text4")))); Exception ex2 = ex.GetMostInner();
Description
Gets the most inner (deepest) exception of a given Exception object
Details
- Author: Jonnidip
- Submitted on: 28-5-2009 15:32:41
- Language: C#
- Type: System.Exception
- Views: 3007
Double click on the code to select all.