View Full Version : catching errors

05-10-2004, 11:39 AM

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(

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

test = new Array(

it throws a wobbler! I have tried doing

test = new Array(
} catch (myError) {

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

05-10-2004, 03: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.