GWT 客户端伞形异常在 Java 中获取完整的错误消息 [英] GWT client umbrellaexception get full error message in java

查看:16
本文介绍了GWT 客户端伞形异常在 Java 中获取完整的错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 GWT,但我发现几乎不可能通过 Chrome 控制台中的当前错误消息找到错误.在本地开发模式下和在 GAE 上托管应用程序时,我都会收到错误消息.我如何获得实际的 Java 错误?它在哪里说我得到了哪一行和什么异常?顺便说一句,我正在寻找的错误是什么?

I'm working with GWT currently but I find it nearly impossible to find errors with the current error messages in the Chrome console. I get the errors both when in local development mode and when I'm hosting the app on GAE. How do I get the actual java error? Where it says which line and what exception I got? And btw what is the error I'm looking for called?

提前致谢!

推荐答案

在 GWT 2.1.1 中出现了 UmbrellaException,它收集了一组子 Throwables.试试这个:

In GWT 2.1.1 here comes UmbrellaException that collects a Set of child Throwables together. Try this:

public void onModuleLoad() {
  GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
    @Override
    public void onUncaughtException(@NotNull Throwable e) {
      ensureNotUmbrellaError(e);
    }
  });
}

其中 ensureNotUmbrellaError 的定义如下:

private static void ensureNotUmbrellaError(@NotNull Throwable e) {
  for (Throwable th : ((UmbrellaException) e).getCauses()) {
    if (th instanceof UmbrellaException) {
      ensureNotUmbrellaError(th);
    } else {
      th.printStackTrace();
    }
  }
}

这篇关于GWT 客户端伞形异常在 Java 中获取完整的错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆