Best way to check for inner exception?

后端 未结 14 2294
说谎
说谎 2020-12-02 11:57

I know sometimes innerException is null

So the following might fail:

 repEvent.InnerException = ex.InnerException.Message; 

Is ther

14条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 12:48

    That's funny, I can't find anything wrong with Exception.GetBaseException()?

    repEvent.InnerException = ex.GetBaseException().Message;
    

提交回复
热议问题