【问题标题】:onFailure is never called when a exception is throwed in server当服务器中抛出异常时,永远不会调用 onFailure
【发布时间】:2013-06-07 20:21:46
【问题描述】:

当从服务器调用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
}

有什么帮助吗?

【问题讨论】:

  • 不知道这里的问题是什么,你能解释一下你的问题吗......而不仅仅是“任何帮助”,以便我们可以更好地帮助你?谢谢
  • 问题是在发生异常时调用 onSuccess 而不是 onFailure。很简单。

标签: java exception gwt editor requestcontext


【解决方案1】:

为什么你认为抛出异常 == 调用 onFailure 方法?您是否分析过代码 - 某个异常处理程序可以捕获您的异常并将其转换为 onFaliure 调用?

【讨论】:

    猜你喜欢
    • 2013-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-11
    • 1970-01-01
    • 2014-05-02
    • 2015-03-05
    • 2017-01-23
    相关资源
    最近更新 更多