在GWT 2.7超级开发模式下调试,是否缺少stackTrace?

时间:2016-01-29 13:33:56

标签: java gwt

我刚刚从GWT 2.5.1迁移到2.7并且第一次使用SuperDev模式。 我启用了#34; JavaScript源地图"在Chrome开发工具中。 Chrome控制台中的例外情况如下所示:

com.google.gwt.event.shared.UmbrellaException: Exception caught: For input string: "a"
  at fillInStackTrace_0_g$
  at Throwable_3_g$
  at Exception_3_g$
  at RuntimeException_3_g$
  at UmbrellaException_3_g$
  at UmbrellaException_5_g$
  at fireEvent_1_g$
  at fireEvent_3_g$
  at fireNativeEvent_1_g$
  at onBrowserEvent_2_g$
  at dispatchEventImpl_0_g$
  at dispatchEvent_4_g$
  at dispatchEvent_6_g$
  at apply_0_g$
  at entry0_0_g$
  at <anonymous>
Caused by: java.lang.NumberFormatException: For input string: "a"
  at fillInStackTrace_0_g$
  at Throwable_2_g$
  at Exception_2_g$
  at RuntimeException_2_g$
  at IllegalArgumentException_2_g$
  at NumberFormatException_2_g$
  at forInputString_0_g$
  at __parseAndValidateDouble_0_g$
  at parseDouble_0_g$
  at Double_2_g$
  at valueOf_68_g$
  at onClick_109_g$
  at dispatch_6_g$
  at dispatch_7_g$
  at dispatch_1_g$
  at dispatchEvent_2_g$
  at doFire_0_g$
  at fireEvent_2_g$
  at fireEvent_1_g$
  at fireEvent_3_g$
  at fireNativeEvent_1_g$
  at onBrowserEvent_2_g$
  at dispatchEventImpl_0_g$
  at dispatchEvent_4_g$
  at dispatchEvent_6_g$
  at apply_0_g$
  at entry0_0_g$
  at <anonymous>

OnModuleLoad我正在寻找例外:

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

我如何获得stackTrace? 我尝试了类似这样的事情https://stackoverflow.com/a/24334132/1660637,但无法设法工作。

3 个答案:

答案 0 :(得分:0)

您是否尝试将这些添加到gwt.xml文件中?

<set-property name="compiler.stackMode" value="emulated"/>
<set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true"/>
<set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true"/>

答案 1 :(得分:0)

SuperDevMode,堆栈跟踪和GWT.log的使用有open issue。 GWT 2.8中似乎也有improvements

据我所知,如果你使用普通java.util.logging代替GWT.log,你应该在SDM中获得堆栈跟踪。

答案 2 :(得分:0)

从onModuleLoad调用以下方法。 请注意,必须使用java.util.Logging才能生效。 GWT.log无法正常处理异常。

/ **     *设置一个解除异常的未捕获异常处理程序     *(UmbrellaException)用于SuperDevMode。     * /    private void setUncaughtExceptionHandler()    {       GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler()       {          @覆盖          public void onUncaughtException(Throwable e)          {             可丢弃的展开=展开(e);             BootBox.error(I18NMessages.getMessage(3774)+“\ n \ n”+ unwrapped);             LOGGER.log(Level.EXCEPTION,“onUncaughtException”+ e.getMessage(),unwrapped);          }

     public Throwable unwrap(Throwable e)
     {
        if (e instanceof UmbrellaException)
        {
           UmbrellaException ue = (UmbrellaException) e;
           if (ue.getCauses().size() == 1)
           {
              return unwrap(ue.getCauses().iterator().next());
           }
        }
        return e;
     }
  });

}

LOGGER按以下方式创建

public static final Logger LOGGER = Logger.getLogger("Something");