捕获Throwable是不可取的,原因在不同的帖子中已经阐述。然而,像下面这样构建主函数是否有意义?如果删除Throwable行,则错误将不会被记录。
public static void main(String[] args) {
try {
launchMyApplication();
} catch (SomeCheckedException e) {
//recover if you can, log it if you can't
} catch (Exception e) {
//recover if you can (unlikely), log it if you can't
} catch (Throwable e) {
//Don't try to recover, but log it
logger.error("Oops: {}", e);
}
}
catch(Exception e)
。 - Jivingsmain()
中重新抛出异常。 - assylias