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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

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