Hello,
My goal is to have a unique place where I can handle unhandled exception. I did try GWT.setUncaughtExceptionHandler but it doesn't work as I would expect. In hosted-mode, I can see the stack trace of my exception in Eclipse console window (which is maybe the good behavior):
Uncaught JavaScript exception [java.lang.NullPointerException: test
[... and the stack ...]
However, in web-mode, the onUncaughtException method of the UncaughtExceptionHandler object is never called. Is there something I understand wrong about this? Is there any other way to achieve this?
Here is my simplified code:
My goal is to have a unique place where I can handle unhandled exception. I did try GWT.setUncaughtExceptionHandler but it doesn't work as I would expect. In hosted-mode, I can see the stack trace of my exception in Eclipse console window (which is maybe the good behavior):
Uncaught JavaScript exception [java.lang.NullPointerException: test
[... and the stack ...]
However, in web-mode, the onUncaughtException method of the UncaughtExceptionHandler object is never called. Is there something I understand wrong about this? Is there any other way to achieve this?
Here is my simplified code:
Code:
public class MyApp implements EntryPoint { public void onModuleLoad() { GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable e) { Window.alert("Blabla: " + e); } }); // Use deferred command to catch initialization exceptions DeferredCommand.addCommand(new Command() { public void execute() { onModuleLoadReal(); } }); } private void onModuleLoadReal() { // I do all the init stuff here, if I throw an exception, the onUncaughtException is called properly. However, if an exception is thrown somewhere else in my application, the onUncaughtException is never called in web-mode. } }
Comment