gpt4 book ai didi

gwt - 如何确定为什么在GWT-RPC中触发onFailure?

转载 作者:行者123 更新时间:2023-12-01 08:58:26 25 4
gpt4 key购买 nike

我有一个项目,该项目执行2个RPC调用,然后将用户提供的数据保存在tha数据存储区中。第一个RPC调用正常,但是从第二个开始,我总是收到onFailure()消息。如何确定为什么触发onFailure()?我尝试了caught.getCause(),但未返回任何内容。

feedbackService.saveFeedback(email,studentName,usedTemplates,
new AsyncCallback<String>() {

public void onFailure(Throwable caught) {
// Show the RPC error message to the user
caught.getCause();
Window.alert("Failure!");
}

public void onSuccess(String result) {
Window.alert("Saved!");
}
});

最佳答案

Throwable实例是Exception的实例。您可以检查它是否是这样的自定义异常:

if (caught instanceOf CustomException){

或者,如果您想显示异常消息,则可以使用getMessage():
Window.alert("Failure: " + caught.getMessage());

关于gwt - 如何确定为什么在GWT-RPC中触发onFailure?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14546734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com