给定:Throwable是Exception的超类。
当我阅读有关编写自己的“例外”的文本时,我看到了Throwable在catch块中使用的示例,而其他文本显示new Exception() 在catch块中使用。我还没有看到关于何时应该使用每个的解释。
我的问题是,什么时候应该Throwable使用,什么时候应该new Exception()使用?
在catchorelse块内使用:
throw throwable;
或者
throw new Exception();
