Try/catch in IE 6.0

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dag Sunde

    Try/catch in IE 6.0

    Can anyone shed som light on why i get a syntax error
    on the "catch" statement in the followng code fragment
    running under IE6.0/WinXP SP1?

    try {
    for (var i=0; i < oAreas.length; i++) {

    areaName = marketInfo.XMLD ocument.selectS ingleNode(
    "marketInformat ion/areas/area[areaId='" +
    oAreas.item(i). text +
    "']/areaCode");

    areaBuffer += "<option value='" + oAreas.item(i). text + "'>" +
    areaName.text + "</option>";
    }
    catch (areaError) {
    alert("Possible inconsistency in area definitions, please contact the
    exchange.");
    }

    TIA...

    --
    Dag.


  • Michael Winter

    #2
    Re: Try/catch in IE 6.0

    On Fri, 17 Dec 2004 13:32:58 GMT, Dag Sunde <me@dagsunde.co m> wrote:
    [color=blue]
    > Can anyone shed som light on why i get a syntax error on the "catch"
    > statement in the followng code fragment running under IE6.0/WinXP SP1?
    >
    > try {
    > for (var i=0; i < oAreas.length; i++) {[/color]

    [snip]
    [color=blue]
    > }
    > catch (areaError) {[/color]
    ^
    Because you're missing a closing brace.

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • Dag Sunde

      #3
      Re: Try/catch in IE 6.0

      "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
      news:opsi5m0pqr x13kvk@atlantis ...[color=blue]
      > On Fri, 17 Dec 2004 13:32:58 GMT, Dag Sunde <me@dagsunde.co m> wrote:
      >[color=green]
      > > Can anyone shed som light on why i get a syntax error on the "catch"
      > > statement in the followng code fragment running under IE6.0/WinXP SP1?
      > >
      > > try {
      > > for (var i=0; i < oAreas.length; i++) {[/color]
      >
      > [snip]
      >[color=green]
      > > }
      > > catch (areaError) {[/color]
      > ^
      > Because you're missing a closing brace.
      >[/color]

      Damn! (It's going to be one of those days, I see...)

      Thank's Mike!

      --
      Dag.


      Comment

      • Douglas Crockford

        #4
        Re: Try/catch in IE 6.0

        > Can anyone shed som light on why i get a syntax error[color=blue]
        > on the "catch" statement in the followng code fragment
        > running under IE6.0/WinXP SP1?
        >
        > try {
        > for (var i=0; i < oAreas.length; i++) {
        >
        > areaName = marketInfo.XMLD ocument.selectS ingleNode(
        > "marketInformat ion/areas/area[areaId='" +
        > oAreas.item(i). text +
        > "']/areaCode");
        >
        > areaBuffer += "<option value='" + oAreas.item(i). text + "'>" +
        > areaName.text + "</option>";
        > }
        > catch (areaError) {
        > alert("Possible inconsistency in area definitions, please contact the
        > exchange.");
        > }[/color]

        I ran it through JSLINT and it found that the catch is at the wrong
        depth. You are missing a '}'. If you indented your code properly, this
        kind of error is easier to spot.

        try {
        for (var i = 0; i < oAreas.length; i += 1) {

        areaName = marketInfo.XMLD ocument.selectS ingleNode(
        "marketInformat ion/areas/area[areaId='" +
        oAreas.item(i). text + "']/areaCode");

        areaBuffer += "<option value='" + oAreas.item(i). text + "'>" +
        areaName.text + "</option>";
        }
        }
        catch (areaError) {
        alert("Possible inconsistency in area definitions, " +
        "please contact the exchange.");
        }

        Neatness counts.


        Comment

        • Dag Sunde

          #5
          Re: Try/catch in IE 6.0

          Believe me, it is intended and neat in my editor, I still didn't
          catch it (no pun intended).

          It was just Outlook Express the F*ck'ed it up a little when I
          Posted it.

          :-\

          Thanks!
          [color=blue]
          > I ran it through JSLINT and it found that the catch is at the wrong
          > depth. You are missing a '}'. If you indented your code properly, this
          > kind of error is easier to spot.
          >
          > try {
          > for (var i = 0; i < oAreas.length; i += 1) {
          >
          > areaName = marketInfo.XMLD ocument.selectS ingleNode(
          > "marketInformat ion/areas/area[areaId='" +
          > oAreas.item(i). text + "']/areaCode");
          >
          > areaBuffer += "<option value='" + oAreas.item(i). text + "'>" +
          > areaName.text + "</option>";
          > }
          > }
          > catch (areaError) {
          > alert("Possible inconsistency in area definitions, " +
          > "please contact the exchange.");
          > }
          >
          > Neatness counts.
          >
          > http://www.crockford.com/javascript/lint.html[/color]


          Comment

          Working...