Laliluna Sebastian Hennebrüder

GWT tip - better exception logging on the server

The GWT servlet is not very helpful considering exceptions of the server code. This can easily be improved.

The GWT servlet is not very helpful considering exceptions of the server code. A nested exception gets hidden from the user. This can easily be improved by overriding the process method in a GWT servlet.


public class FooServiceImpl extends RemoteServiceServlet implements FooService {

	final Logger logger = LoggerFactory.getLogger(StockServiceImpl.class);

// ...
 @Override
 public String processCall(String payload) throws SerializationException {
   try {
    return super.processCall(payload);
   } catch (RuntimeException e) {
    logger.warn("Service Layer threw exception: ", e);
    // normally bad style but we need to throw again to inform the client
    throw e;
   }
 }
}

Best Regards

Sebastian Hennebrueder