Is there a benefit to JUST a “throw” in a catch?

后端 未结 11 1282
醉梦人生
醉梦人生 2021-02-07 06:42

Been having a \"heated debate\" with a colleague about his practice of wrapping most of his functions in a try/catch but the catch has JUST a \"throw\" in it e.g.



        
11条回答
  •  猫巷女王i
    2021-02-07 07:11

    The reason you have a lone throw inside a catch rather than throwing a new exception is because this causes the original stack trace/exception data to be preserved. And one reason you might do this is because you can now set a break-point there for debugging.

提交回复
热议问题