首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

Unhandled exception type UsersException解决方法!

2014-01-26 
以下是我的代码,大家帮我看一下是什么问题: public class UsersException extends Exception{ public Users

以下是我的代码,大家帮我看一下是什么问题:
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
------解决方法--------------------------------------------------------
没有处理自己抛出的异常了。。。
 

        

热点排行