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

可紊 提交于 2020-01-15 07:34:51

问题


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.


回答1:


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.




回答2:


Addition to Thomas post, a link how to implement it.

Implement this and you get your StackTrace and find the Problem: http://cleancodematters.com/2011/05/29/improved-exceptionhandling-with-gwts-requestfactory/

Takes five minutues and saves you much time now and in future.



来源:https://stackoverflow.com/questions/10471294/requestfactory-error-getexceptiontype-returns-null-in-receiveronfailure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!