Proper way to find the innermost exception?

前端 未结 4 1946
孤独总比滥情好
孤独总比滥情好 2021-02-08 06:16

I\'m working with some classes which, when throwing, have a relatively deep InnerException tree. I\'d like to log and act upon the innermost exception which is the one having th

4条回答
  •  灰色年华
    2021-02-08 06:46

    I think you can get the innermost exception using the following code:

    public static Exception getInnermostException(Exception e) { 
        return e.GetBaseException(); 
    }
    

提交回复
热议问题