I am changing my code from
Implementation 1 :
public User getUser(String userid) {
User user;
try {
// some code to get User
}catch(InterruptedException e) {
throw new CustomException();
}
return user;
}
to
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();
}
}
Implementation 2 gives compilation error that user might not be initialized, can someone help what am I missing here, seems very weird to me.