Search code examples
gwtrequestfactory

RequestFactory: error.getExceptionType() returns null in Receiver#onFailure


In the server side i have:

public void throwException() throws Exception {
        throw new NullPointerException("fslkdjflks");
}

in the client side i have:

_requestFactory.myService().throwException().fire(new Receiver<Void>() {

            @Override
            public void onSuccess(Void response) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onFailure(ServerFailure error) {
                // TODO Auto-generated method stub
                Window.alert(error.getExceptionType() + " " + error.getMessage());

            }

        });

error.getExceptionType() returns null and not the type of the exception. Any idea why?

Thanks, Gilad.


Solution

  • The default ExceptionHandler (DefaultExeptionHandler) does not populate the exceptionType and stackTraceString. If you want them, you have to provide your own ExceptionHandler by extending RequestFactoryServlet.