读书人

Unhandled exception type UsersExcep

发布时间: 2014-01-26 14:32:30 作者: rapoo

以下是我的代码,大家帮我看一下是什么问题:
public class UsersException extends Exception{
public UsersException(){

}

public UsersException(String msg){
super(msg);
}
}


public void addUser(String username, String password) {
// TODO Auto-generated method stub
try{
Users users = new Users();
users.setUsername(username);
users.setPassword(password);
usersDao.save(users);
}catch(Exception e){
log.debug(e.getMessage());
throw new UsersException( "发生错误 ");
}
}

以上代码编译都不能够通过的
会提示:Unhandled exception type UsersException

------解决方法--------------------------------------------------------
public void addUser(String username, String password)
改成
public void addUser(String username, String password) throws UsersException
------解决方法--------------------------------------------------------
没有处理自己抛出的异常了。。。

        

读书人网 >Java Exception

热点推荐