View Full Version : Exception Handlng Best Practice

15 Jul 2010, 2:16 AM
Hi all

maybe this is a GWT related question, maybe on GXT there is a special trick to use....
The problem is how can i manage exceptions during an RPC call.
The is the scenario

on GXT client side:
the GXT-Controller do an RPC call to the RemoteImpl (es. doLogin(username, passwd))

on the GXT server side:
- the RemoteImpl forward the call to a session bean in a EJB Layer
- the session bean launch an application exception (es. UserInvalidStateException); this exception is boundled in the ejb's .jar archive
- the RemoteImpl catch that exception in an custom GXT exception and re-throws to the controller
- the controller catch that exception and dispatch an ErrorEvento to display a popup

is that flow correct? Maybe is there too much steps?
any suggestion to semplificate this catch-rethrow-catch chain?


Colin Alworth
17 Jul 2010, 8:07 AM
As annoying as it is to catch and rethrow, our approach has been to consider that exceptions thrown to client are just like models objects - everything has to be translated to something GWT can turn into javascript. We have a RemoteServiceServlet subclass that provides an exception handling method which is used in in RPC method catch blocks to rethrow exceptions the client can understand and handle.