c# - Proper way to find the innermost exception? -


i'm working classes which, when throwing, have relatively deep innerexception tree. i'd log , act upon innermost exception 1 having real reason problem.

i'm using similar to

public static exception getinnermostexception(exception e) {     while (e.innerexception != null) {         e = e.innerexception;     }     return e; } 

is proper way handle exception trees?

i think can innermost exception using following code:

public static exception getinnermostexception(exception e) {      return e.getbaseexception();  } 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -