当从服务器调用persist() 方法时,在验证电子邮件的唯一性后会引发异常。
问题是调用了来自客户端的 onSuccess 方法,而不是 onFailure。这是代码。
RequestContext req = driver.flush();
if (req.isChanged() && !driver.hasErrors()) {
saveButton.setEnabled(false);
req.fire(new Receiver<Void>() {
@Override
public void onSuccess(Void response) {
//anything
}
@Override
public void onFailure(ServerFailure error) {
//anything
}
});
}
public User persist() throws GenericException{ // extends from Exception
//query in database
throw new GenericException("Email must be unique");
//save case is correct
}
有什么帮助吗?