Thursday, October 27, 2011

Re: Handling authorization exception from server to client

No, it's not a "general failure", it's only a failure for one invocation. Look at few lines down in AbstractRequestContext:

      Set<Throwable> causes = null;
      for (int i = 0, j = invocations.size(); i < j; i++) {
        try {
          if (response.getStatusCodes().get(i)) {
            invocations.get(i).onSuccess(response.getInvocationResults().get(i));
          } else {
            ServerFailureMessage failure = AutoBeanCodex.decode(
                MessageFactoryHolder.FACTORY, ServerFailureMessage.class,
                response.getInvocationResults().get(i)).as();
            invocations.get(i).onFail(
                new ServerFailure(failure.getMessage(),
                    failure.getExceptionType(), failure.getStackTrace(),
                    failure.isFatal()));
          }

response.getStatusCodes().get(i) reads from the "S" (in your case, returns 'false', for i==0), and response.getInvocationResults().get(i) reads from the "I" (in your case, a ServerFailureMessage).

To be crystal clear:
requestContext.myMethod(arguments).to(new Receiver<X>() {
    @Override
    public void onSuccess(X response) {
        // won't get here
    }
    @Override
    public void onFailure(ServerFailureMessage error) {
        // will get there: the myMethod invocation failed; its Receiver's onFailure is called
    }
});
requestContext.fire(new Receiver<Void>() {
    @Override
    public void onSuccess(Void response) {
        // will get there: the myMethod invocation failed, but the whole "batch" succeeded: the context could have had other invocations that succeeded
    }
});

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/R-fuY5miJ0oJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment