Is there a difference between “throw” and “throw ex”?

前端 未结 10 2366
夕颜
夕颜 2020-11-22 01:08

There are some posts that asks what the difference between those two are already.
(why do I have to even mention this...)

But my question is different in a way

10条回答
  •  梦如初夏
    2020-11-22 01:42

    When you do throw ex, that thrown exception becomes the "original" one. So all previous stack trace will not be there.

    If you do throw, the exception just goes down the line and you'll get the full stack trace.

提交回复
热议问题