简体   繁体   English

Beanshell catch(ex):Exception还是Throwable?

[英]Beanshell catch(ex): Exception or Throwable?

What type of exception is caught by the beanshell catch(ex): Exception or Throwable?. beanshell catch(ex)捕获了什么类型的异常:Exception或Throwable?。

Example: 例:

try {
    .... } catch (ex) {     }

That loosely typed catch will catch everything " Throwable ." 这种松散类型的捕获物将捕获所有“ Throwable” That will include Errors , Exceptions and their myriad children. 这将包括错误例外和他们无数的孩子。 You can easily confirm this with: 您可以通过以下方式轻松确认:

try {
  new Throwable("Something Exceptional");
} catch (ex) {
  System.err.println(ex.getMessage());
}

Throwable is a superclass (essentially) of Exception--anything that Exception catches will also be caught by Throwable. Throwable是Exception的超类(本质上) - Exception捕获的任何东西也将被Throwable捕获。 In general usage they are the same, you rarely (if ever) see other throwable types. 在一般用法中它们是相同的,你很少(如果有的话)看到其他可抛出的类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM