1
votes

When a called the persist() method from server, a exception is throwed after a validation in uniques of a email.

The problem is that onSuccess method from client is called, instead of onFailure. Here is the code.

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
}

Any help?

1
Not sure what the question is here , can you explain your problem more ...instead of just "Any help" so we can better help you ?Thanks - grepit
The problem is then onSuccess is called instead of the onFailure when a excetion happens. Simple. - juliano

1 Answers

0
votes

Why do you think that throwing exception == calling onFailure method? Did you analyzed code - is somewhere exception handler that catches your exceptions and converts them to onFaliure calls?