我试过
I tried
public void onFailure(Throwable caught) { Throwable cause = caught.getCause(); String causeStr = (cause==null) ? "" : ", "+cause.getMessage(); errorLabel.setText(SERVER_ERROR + ": " + caught.getMessage() + causeStr);但是原因始终为空,并且 caught.getMessage()总是等于非常通用的 500服务器上的调用失败;详情请参阅服务器日志。我想从服务器抛出IllegalArgumentExceptions并能够在客户端显示它:
But cause is always null and caught.getMessage() always equals the very generic 500 The call failed on the server; see server log for details. I want to throw IllegalArgumentExceptions from the server and be able to show it on the client:
throw new IllegalArgumentException("Email address is invalid.");推荐答案
您可以使用 com。 google.gwt.core.client.GWT.UncaughtExceptionHandler 来捕获服务器上的异常,然后抛出自己的异常
You can use com.google.gwt.core.client.GWT.UncaughtExceptionHandler to catch the exception on the server, and then throw your own exception that
实现 Serializable 和
在源文件夹中定义可以接受(并编译)客户端。
is defined in a source folder that is acccessible to (and compiled for) the client.
更多推荐
如何使用GWT获取服务器端异常消息?
发布评论