[英]Debugging in GWT 2.7 Super Dev Mode, stackTrace is missing?
I just migrated from GWT 2.5.1 to 2.7 and first time using SuperDev Mode. 我刚刚从GWT 2.5.1迁移到2.7并且第一次使用SuperDev模式。 I have enabled "JavaScript source maps" in Chrome dev tools. 我在Chrome开发工具中启用了“JavaScript源地图”。 In Chrome Console exception looks like this: 在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 I am cacthing exceptions: OnModuleLoad我是cacthing例外:
GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
@Override
public void onUncaughtException(Throwable e) {
GWT.log(e);
}
});
How can I get stackTrace? 我怎样才能获得stackTrace? I tried something like this https://stackoverflow.com/a/24334132/1660637 but couldn't manage to work. 我试过这样的事情https://stackoverflow.com/a/24334132/1660637但无法正常工作。
Did you try adding these into your gwt.xml file? 您是否尝试将这些添加到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"/>
There is an open issue for SuperDevMode, stacktraces and the use of GWT.log
. SuperDevMode,堆栈跟踪和GWT.log
的使用存在一个未解决的问题 。 Also there seem to be improvements in GWT 2.8. GWT 2.8似乎也有所改进 。
As far as I know if you use the normal java.util.logging
instead of GWT.log
you should get stack traces in SDM. 据我所知,如果你使用普通的java.util.logging
而不是GWT.log
你应该在SDM中获得堆栈跟踪。
Call the below method from your onModuleLoad. 从onModuleLoad调用以下方法。 Note that you must use java.util.Logging for this to work. 请注意,必须使用java.util.Logging才能生效。 GWT.log does not work correctly for exceptions. GWT.log无法正常处理异常。
/** * Set an uncaught exception handler that unwraps the exception * (UmbrellaException) for SuperDevMode. / ** *设置一个未捕获的异常处理程序,为SuperDevMode解包异常*(UmbrellaException)。 */ private void setUncaughtExceptionHandler() { GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { @Override public void onUncaughtException(Throwable e) { Throwable unwrapped = unwrap(e); BootBox.error(I18NMessages.getMessage(3774) + "\\n\\n" + unwrapped); LOGGER.log(Level.EXCEPTION, "onUncaughtException " + e.getMessage(), unwrapped); } * / private void setUncaughtExceptionHandler(){GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler(){@ Override public void onUncaughtException(Throwable e){Throwable unwrapped = unwrap(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;
}
});
} }
And the LOGGER is create in the following way LOGGER以下列方式创建
public static final Logger LOGGER = Logger.getLogger("Something");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.