Try/catch in IE 6.0

D

Dag Sunde

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.XMLDocument.selectSingleNode(
"marketInformation/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...
 
M

Michael Winter

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++) {
[snip]

}
catch (areaError) {
^
Because you're missing a closing brace.

[snip]

Mike
 
D

Dag Sunde

Michael Winter said:
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++) {
[snip]

}
catch (areaError) {
^
Because you're missing a closing brace.

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

Thank's Mike!
 
D

Douglas Crockford

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.XMLDocument.selectSingleNode(
"marketInformation/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.");
}

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.XMLDocument.selectSingleNode(
"marketInformation/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
 
D

Dag Sunde

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top