Re: exception not caught in a javascript constructor in IE
I finally managed to reproduce this pb outside of gwt. It seems to be due to the fact the js is loaded inside an iframe (which is the case of the js generated by gwt). Here is a simple example to reproduce it. main.html function MyObject(){ throw "String thrown"; }; //This function is the workaround to the pb explained in my previous post function wrappingMyObjectConstructor(){ try{ new MyObject(); } catch(e){ throw(e); } } iframe.html function buggy(){ try{ new parent.window.MyObject(); } catch(e){ alert(e); } } function notBuggy(){ try{ parent.window.wrappingMyObjectConstructor(); } catch(e){ alert(e); } } buggy : constructor called directly not buggy : constructor called via wrapping function On 5 jan, 18:08, "Ian Petersen" wrote: > On Mon, Jan 5, 2009 at 9:02 AM, blissteria wrote: > > 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? > > You may have found a bug in GWT. If GWT can catch thrown strings in > the second case but not in the first case, then I think there's a > problem with the exception mapping between the languages. You might > want to file a bug and, if you do, try to include a really good repro > case. > > 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 -~--~~~~--~~--~--~---
Re: exception not caught in a javascript constructor in IE
On Mon, Jan 5, 2009 at 9:02 AM, blissteria wrote: > 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? You may have found a bug in GWT. If GWT can catch thrown strings in the second case but not in the first case, then I think there's a problem with the exception mapping between the languages. You might want to file a bug and, if you do, try to include a really good repro case. 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 -~--~~~~--~~--~--~---
Re: exception not caught in a javascript constructor in IE
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" wrote: > On Mon, Jan 5, 2009 at 8:37 AM, blissteria 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 > > > > > 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 -~--~~~~--~~--~--~---
Re: exception not caught in a javascript constructor in IE
On Mon, Jan 5, 2009 at 8:37 AM, blissteria 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 > > > 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 -~--~~~~--~~--~--~---
exception not caught in a javascript constructor in IE
Hi, I have a pb related to InternetExplorer and probably GWT (but I'm not convinced) since I have not managed to reproduce it outside of my gwt project. 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 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? Regards, Blisseria. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---