RequestFactory:error.getExceptionType()在Receiver#onFailure中返回null

Gil*_*lad 2 gwt requestfactory

在服务器端我有:

public void throwException() throws Exception {
        throw new NullPointerException("fslkdjflks");
}
Run Code Online (Sandbox Code Playgroud)

在客户端我有:

_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());

            }

        });
Run Code Online (Sandbox Code Playgroud)

error.getExceptionType()返回null,而不是异常的类型.知道为什么吗?

谢谢,吉拉德.

Tho*_*yer 5

默认ExceptionHandler(DefaultExeptionHandler)不会填充exceptionTypestackTraceString.如果你想要它们,你必须ExceptionHandler通过扩展RequestFactoryServlet来提供自己的.


Sam*_*Sam 5

除了Thomas帖子,还有一个如何实现它的链接.

实现这一点,你得到你的StackTrace并找到问题:http: //cleancodematters.com/2011/05/29/improved-exceptionhandling-with-gwts-requestfactory/

需要五分钟,为您现在和将来节省大量时间.