Exceptions - Throw and catch right away

前端 未结 2 1531
终归单人心
终归单人心 2021-01-22 10:16

Does it make sense to throw an exception and directly catch it just to print error?

if(...){

} else {
   try{
      throw new Exception();
   } catch (Exception         


        
2条回答
  •  無奈伤痛
    2021-01-22 11:12

    I think it might be useful only if you explicitly want to send the Exception to a log file with a LOGGER (into the catch block), or register it in an especific way.

提交回复
热议问题