try catch in java/python/scala

try catch是代码里面非常实用捕获异常的方式

 

in java:

try{} catch (*Exception e) {e.printStackTrace(); dosomething(); } finally{}

 

in scala: 

try{} catch { case e : * Exception => { e.printStackTrace(); dosomething();}}

 

in python 2.6 and before ?:

import traceback

try:

except Exception, e:

  traceback.print_exec()

 

in python 2.7 and later:

import traceback

try:

except Exception as e:

  traceback.print_exec()

 

posted @ 2018-02-09 00:06  JimTheMan  阅读(119)  评论(0)    收藏  举报