【发布时间】:2020-01-14 01:15:12
【问题描述】:
我正在更改我的代码
Implementation 1 :
public User getUser(String userid) {
User user;
try {
// some code to get User
}catch(InterruptedException e) {
throw new CustomException();
}
return user;
}
到
Implementation 2 :
public User getUser(String userid) {
User user;
try {
// some code to get User
}catch(InterruptedException e) {
SomeHandlerInProject.throwCustomErr();
}
return user;
}
class SomeHandlerInProject {
public static void throwCustomErr() {
throw new CustomException();
}
}
实施 2 给出了用户可能未初始化的编译错误,有人可以帮助我在这里缺少什么,对我来说似乎很奇怪。
【问题讨论】:
-
请发布确切的编译错误。
-
[ERROR] /pathtoClassFile.java:[1239,16] 变量用户可能尚未初始化
标签: java exception error-handling refactoring throws