gpt4 book ai didi

java - 编译器提示多个异常处理

转载 作者:行者123 更新时间:2023-11-30 08:44:17 25 4
gpt4 key购买 nike

尝试使用时

catch( EntityExistsException | PersistenceException eeEx)

编译器提示:

No exception of type Object can be thrown; an exception type must be a subclass of Throwable

我正在为项目使用编译器设置为 java 8 的 eclipse luna

最佳答案

我刚遇到这个,它快把我逼疯了。
我通过将 URISyntaxException 添加到现有的 catch 中来创建一个 multi-catch 异常处理程序。
Eclipse 提示

No exception of type Object can be thrown; an exception type must be a subclass of Throwable

我终于注意到我没有添加相应的导入语句所以eclipse不知道新添加的异常的类型。
如果 eclipse 会提示

URISyntaxException cannot be resolved to a type

这是异常本身的意思。
当它是 multi-catch 的一部分时,您得到的错误是不直观的。

关于java - 编译器提示多个异常处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33854791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com