GWT client umbrellaexception get full error messag

2020-03-28 16:21发布

问题:

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?

Thanks in advance!

回答1:

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);
    }
  });
}

Where ensureNotUmbrellaError is defined as follows:

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