Thanks for the really quick answer!!! I can modify the script I include but I'd rather not. The calls of "throw" are already wrapped in a function therefore your solution could be envisaged.
There is another solution that works but I do not trully understand why. I wrap the call of "new MyObject()" in a function defined in the foo.js file : function wrappingMyObjectConstructor() { try { return new MyObject(); } catch (e) { throw e; } } and calling wrappingMyObjectConstructor in JSNI works fine in IE. This is a hack, it works, but does anyone know how to avoid this or can explain this? Thanks On 5 jan, 17:43, "Ian Petersen" <ispet...@gmail.com> wrote: > On Mon, Jan 5, 2009 at 8:37 AM, blissteria <blisste...@hotmail.com> wrote: > > Let foo.js a javascript file containing: > > function MyObject(){ > > throw "String Thrown"; > > }; > > > In my Module.gwt.xml I add the following line to include the script > > <script src="foo.js" /> > > > Then in any java file of my application, in the click method of a > > clickListener for instance, I call the function "createMyObject" > > defined as: > > public native void createMyObject()/*-{ > > new $wnd.MyObject(); > > }-*/; > > > The call of this function is surrounded by a try/catch block : > > try { > > createMyObject(); > > } > > catch (Exception e){ > > Window.alert(e); > > } > > > This works fine in firefox 2 and 3 but not in IE (6 and 7). In IE I > > got an "exception rised but not caught" error and therefore no > > alert... > > > What do you think of this problem? > > I'm just guessing here because I don't know how GWT maps native > Javascript "exceptions" into Java. I think your problem might be > related to the fact that you're throwing a string, not an Exception > and you're catching an Exception, not a string. > > Do you have control over the script you're trying to include? Can you > modify the throw statement to call into a Java method that throws a > "real" exception? Could you factor the throw statement into a helper > function that gets substituted by a JSNI method when the script is > invoked from a GWT app? > > Ian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---