Loading ...
Sorry, an error occurred while loading the content.
 

Exception in connection-debug.js, it's inside a try/catch but...should I worry?

Expand Messages
  • hostilefork
    Hello all, I just found YUI and Ext-Js and read they could be mixed together if you use a YUI adapter . So after following the basic instructions of library
    Message 1 of 4 , Oct 29, 2007
      Hello all,

      I just found YUI and Ext-Js and read they could be mixed together if you use a YUI "adapter".  So after following the basic instructions of library ordering, I set about on a fairly naive quest to embed a YUI drag and drop demo into a window of Ext-Js's Web Desktop .

      Amazingly what I did worked.  I simply took the global variables (slots, players, Event, DDM) and made them members of the created window object.  I then substituted the HTML of the drag and drop space "<div id="workarea">..blahblah...</div>" for the "<p>something useful would be in here</p>" that was in the default for blank windows in the ext-js sample.  Suddenly I could drag and drop constrained squares inside a window alongside the ExtJs "Grid Window" and "Accordion Window"!  I was shocked.

      But I use Firebug with the "Break on all Errors" option.  And clicking in the ExtJs grid window now causes me to temporarily halt in YUI's connection-debug.js on line 240.  It's a little snip of code in _hasSubmitListener enclosed within a try/catch block, like so:

      237 try
      239 var obj = YAHOO.util.Event.getTarget(e);
      240 if(obj.type.toLowerCase() == 'submit'){
      241 YAHOO.util.Connect._submitElementValue = encodeURIComponent(obj.name) + "=" + encodeURIComponent(obj.value);
      244 catch(e){}

      What's happening is that obj is div.x-grid3-cell-inner, and its .type is undefined.  Of course if I just ignore this, the program runs along smoothly because the error is "caught" by the try/catch block.  But if type being undefined is one of the conditions that one is to expect and is normal, I'd rather it be handled explicitly so it didn't get Firebug to break on it as an error:

      if (obj.type != undefined)
         if (obj.type.toLowerCase() == 'submit') ...


      However if this is truly a condition that should never occur if I'm mixing the frameworks properly (e.g. any time this method is run one should expect the obj to have a type), I'd appreciate any pointers to where I should look to do it right.  And also if that's the case, it would seem the obj.type.toLowerCase() should be moved outside of the try/catch so that people who aren't using Firebug can know they've got an error in their code!

      Thanks much,
      HF.
    • tssha
      ... That will work. Or, you can evaluate the condition in one If statement: if(obj.type !== undefined && obj.type.toLowerCase() == submit ) You can then
      Message 2 of 4 , Oct 30, 2007
        --- In ydn-javascript@yahoogroups.com, "hostilefork" <hostilefork@...>
        wrote:
        >
        > Hello all,
        >
        > I just found YUI and Ext-Js and read they could be mixed together if you
        > use a YUI "adapter". So after following the basic instructions of
        > library ordering, I set about on a fairly naive quest to embed a YUI
        > drag and drop demo
        > <http://developer.yahoo.com/yui/examples/dragdrop/dd-groups.html> into
        > a window of Ext-Js's Web Desktop
        > <http://extjs.com/deploy/dev/examples/desktop/desktop.html> .
        >
        > Amazingly what I did worked. I simply took the global variables (slots,
        > players, Event, DDM) and made them members of the created window object.
        > I then substituted the HTML of the drag and drop space "<div
        > id="workarea">..blahblah...</div>" for the "<p>something useful would be
        > in here</p>" that was in the default for blank windows in the ext-js
        > sample. Suddenly I could drag and drop constrained squares inside a
        > window alongside the ExtJs "Grid Window" and "Accordion Window"! I was
        > shocked.
        >
        > But I use Firebug with the "Break on all Errors" option. And clicking
        > in the ExtJs grid window now causes me to temporarily halt in YUI's
        > connection-debug.js on line 240. It's a little snip of code in
        > _hasSubmitListener enclosed within a try/catch block, like so:
        >
        > 237 try 238 { 239 var obj = YAHOO.util.Event.getTarget(e); 240
        > if(obj.type.toLowerCase() == 'submit'){ 241
        > YAHOO.util.Connect._submitElementValue = encodeURIComponent(obj.name) +
        > "=" + encodeURIComponent(obj.value); 242 } 243 } 244
        > catch(e){}
        > What's happening is that obj is div.x-grid3-cell-inner, and its .type is
        > undefined. Of course if I just ignore this, the program runs along
        > smoothly because the error is "caught" by the try/catch block. But if
        > type being undefined is one of the conditions that one is to expect and
        > is normal, I'd rather it be handled explicitly so it didn't get Firebug
        > to break on it as an error:
        >
        > if (obj.type != undefined)
        > if (obj.type.toLowerCase() == 'submit') ...
        That will work. Or, you can evaluate the condition in one If
        statement: if(obj.type !== undefined && obj.type.toLowerCase() ==
        'submit')

        You can then remove the try/catch. It exists for conditions where
        obj.type is undefined, but the revised evaluation for the property and
        the type value will be sufficient.

        Regards,
        Thomas
      • hostilefork
        ... Hi Thomas, Thanks for the response. If this is truly the case that the try/catch is being used to detect undefines, does anyone consider removing it to be
        Message 3 of 4 , Oct 30, 2007
          > --- In ydn-javascript@yahoogroups.com, "hostilefork" <hostilefork@>
          > wrote:
          > But if type being undefined is one of the conditions that
          > one is to expect and is normal, I'd rather it be handled
          > explicitly so it didn't get Firebug
          > to break on it as an error:
          > >
          > > if (obj.type != undefined)
          > >     if (obj.type.toLowerCase() == 'submit') ...

          --- In ydn-javascript@yahoogroups.com, "tssha" <tsha@...> wrote:
          >
          > That will work. Or, you can evaluate the condition in one If
          > statement: if(obj.type !== undefined && obj.type.toLowerCase() ==
          > 'submit')
          >
          > You can then remove the try/catch.  It exists for conditions where
          > obj.type is undefined, but the revised evaluation for the property and
          > the type value will be sufficient.

          Hi Thomas,

          Thanks for the response.  If this is truly the case that the try/catch is being used to detect undefines, does anyone consider removing it to be an issue worth addressing in the main yui source files?  It seems like this isn't a good application of exception handling (since it's not a
          truly "exceptional" or unpredictable case), and I know I must not be the only one who runs Firebug in "Break on All Errors" mode!

          I wrote up a little summary  of what I was doing.  So if there's a consensus on this issue it might make the article more helpful if I
          can explain what this code is doing, why it's "o.k." to ignore it when you mix the frameworks and patch out the try/catch...or if it's not then why it isn't.  Newbies like me would much appreciate it!

          HF.
        • tssha
          ... This is progress and will be introduced in the next version -- 2.4.0. Regards, Thomas
          Message 4 of 4 , Oct 30, 2007
            --- In ydn-javascript@yahoogroups.com, "hostilefork" <hostilefork@...>
            wrote:

            > Hi Thomas,
            >
            > Thanks for the response. If this is truly the case that the try/catch
            > is being used to detect undefines, does anyone consider removing it to
            > be an issue worth addressing in the main yui source files? It seems

            This is progress and will be introduced in the next version -- 2.4.0.

            Regards,
            Thomas
          Your message has been successfully submitted and would be delivered to recipients shortly.