...

View Full Version : catching errors



homerUK
05-10-2004, 10:39 AM
Hey,

to my delight I have just found the TRY CATCH() method of Internet Explorer... Ive used it through out my program and its great...

but I was wondering if there was a way to use it to catch problems with arrays when they are loaded??

eg: my array looks like this



test = new Array(
"value1","value2","value3"
)


but if you add an extra comma at the end, eg



test = new Array(
"value1","value2","value3",
)


it throws a wobbler! I have tried doing



try
{
test = new Array(
"value1","value2","value3",
)
} catch (myError) {
alert("error");
}


but that doesnt work. Does any one know of a good way to stop this happening? so to trap the error?
thanks....

Danne
05-10-2004, 02:41 PM
That's a syntax error. The try-catch catches only runtime errors as far as I know.



test = ["value1","value2","value3",]

works in IE6 and Moz though. I'm not sure why. Anyway in IE6 the test.length is 4 and the last element gets the value undefined. In Mozilla the test.length is 3.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum