Hi Itzik, An alternative to propagating the exception is to create an object with details of the outcome of the RPC call regardless of success or an error (other than an error connecting to the server).
In this object have methods to store and retrieve error codes and messages so that your client can interpret them and inform the user or perform other required actions. So in my class, I put the following methods: setStatusCode(int statusCode) int getStatusCode() setStatusMessage(String statusMessage) String getStatusMessage() The server creates one of these objects each time an RPC call is made. Then when your client receives the message, it can read the status code and act appropriately, displaying the status message as necessary. Some overhead, but it made my life much easier when it came to error handling. Cheers, Jin Cheers, Jin On Oct 7, 7:31 pm, Itzik Yatom <[email protected]> wrote: > Hi, > > Our project uses GWT and App engine. We have a problem with catching > exceptions. > When we define an exception as part of method signature in our RPC > asynch interface and implement it at the server, the client side > catches it and everything works fine. > > But in other 'unusual' case we have problems with catching the > exception: > We do some general checks in all our RPC server methods, for example > checking authorization of current user, and if user is not authorized > we throw a specific exception. > For that purpose we have extended the class RemoteServiceServlet and > overridden the method onAfterRequestDeserialized, in this method if > user is not authorized we throw our UnAuthorizedException exception. > > The problem is that the client side gets just a general > StatusCodeException with code 500 (internal server error). I have > found this relevant code at RpcCallbackAdapter.onResponseReceived: > . > . > if (statusCode != Response.SC_OK) { > caught = new StatusCodeException(statusCode, encodedResponse); > . > . > The question is how we can get the actual exception in this case? is > there a way for the client to get the returned Response object ? Any > other direction ? > > Thanks > Itzik Yatom -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
