hi,
is it possible to do error checking with javascript?
If an error shows up, I want it to continue running the code, but perhaps miss out a bit.
Thanks
Nick
Printable View
hi,
is it possible to do error checking with javascript?
If an error shows up, I want it to continue running the code, but perhaps miss out a bit.
Thanks
Nick
If there is a syntax error, there is nothing you can do, the script will die. If you want to make sure you avoid errors, you can build your scripts to do their error handling. Always make sure an object has been instantiated before you call a property/method. Use conditionals to confirm assignments, always double check user input, yadda yadda.
Error: 'undefined' is null or not an object
- is the error i get. I know why i get it, and there is no easy fix for it! Is there a way i can miss it?
Cheers
Can't you do something to do with the try, catch and throw keywords?
to be honest i don't know what they are.
I am not the best javascript programmer in the world you see!!!
You error sounds like you are trying to access a variable that is not defined. Either you haven't declared it and assigned a value, or you think you have instantiated an object that you haven't.
The throw/catch stuff would work great.
Try the links in my sig.
I like the try-catch-finally error handling. I use it in Java, but didn't know that JavaScript had it too.
You can also test to see if a variable is defined or not. I think it's:
if (variable) {}
Which will only be true if the variable exists or is defined. Also, you can further check:
if (variable != null) {}
to verify if something is defined, yet is null.
With these, you can test out before it errors out.
cudabean
Can you post you code so we can see where the problem is?