Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: catching errors

  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post

    catching errors

    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

    Code:
    test = new Array(
    "value1","value2","value3"
    )
    but if you add an extra comma at the end, eg

    Code:
    test = new Array(
    "value1","value2","value3",
    )
    it throws a wobbler! I have tried doing

    Code:
    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....

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's a syntax error. The try-catch catches only runtime errors as far as I know.

    Code:
    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.
    /Daniel


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •