Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Uncaught JavaScript exception when formula field results in divide by zero

    I have a formula field in a grid with this definition.
    <userFormula text="1-(C/R)">
    <formulaVars>
    <C>landedCost</C>
    <R>homeRetail</R>
    </formulaVars>
    </userFormula>

    When the homeRetail field in the record is zero I get the following exception when the grid rows are being loaded. If I remove the formula column the problem goes away.

    Is there some way to protect a formula from this sort of divide by zero error?

    Code:
    10:44:31.497 [ERROR] [ipgui] Uncaught exception escaped
    com.google.gwt.dev.shell.HostedModeException: invoke arguments: JS double value -Infinity out of range for a int
        at com.google.gwt.dev.shell.JsValueGlue.getIntRange(JsValueGlue.java:256)
        at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:144)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:65)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
        at sun.reflect.GeneratedMethodAccessor133.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Thread.java:680)
    Ultimately I see this error in the Eclipse console
    Code:
    Uncaught JavaScript exception [uncaught exception: [Exception... "Cannot modify properties of a WrappedNative"  nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)"  location: "JS frame :: http://127.0.0.1:8888/ipgui/sc/modules/ISC_Core.js?isc_version=7.0.js :: <TOP_LEVEL> :: line 946"  data: no]] in , line 0

    #2
    Hmm - it looks like we should be handling this. Here's a simple test case:

    Code:
    public class DivideByZero implements EntryPoint {
        public void onModuleLoad() {
            final ListGrid g = new ListGrid();
            ListGridField f1 = new ListGridField("f1");
            f1.setType(ListGridFieldType.INTEGER);
            ListGridField f2 = new ListGridField("f2");
            f2.setType(ListGridFieldType.INTEGER);
            
            ListGridRecord r1 = new ListGridRecord();
            r1.setAttribute("f1", 100);
            r1.setAttribute("f2", 1);
            
            ListGridRecord r2 = new ListGridRecord();
            r2.setAttribute("f1", 100);
            r2.setAttribute("f2", 0);
            
            g.setFields(f1, f2);
            g.setData(new ListGridRecord[] {r1, r2});
            
            g.setWidth(300);
            g.setHeight(200);
            g.draw();
            
            Button b = new Button("Show Formula Builder");
            b.setTop(250);
            b.addClickHandler(new ClickHandler() {
                
                @Override
                public void onClick(ClickEvent event) {
                    g.addFormulaField();
                    
                }
            });
            
            b.draw();
        }
    
    }
    If you hit the button and enter a formula that divides field 1 by field 2, you end up with "Infinity" for the case where it's a divide-by-zero and no errors.

    There's a chance this is browser-specific - are you seeing the bug on a specific browser config or on all browsers?
    Otherwise there must be something different about your code - how are you defining your formulae in your code? Any chance you can give us a runnable test case that trips the bug?

    Thanks
    Isomorphic Software

    Comment

    Working...
    X