|
-
May 13th, 2002, 09:36 AM
#1
Thread Starter
Fanatic Member
javascript error checking
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
-
May 13th, 2002, 09:54 AM
#2
Frenzied Member
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.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
May 13th, 2002, 09:57 AM
#3
Thread Starter
Fanatic Member
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
-
May 13th, 2002, 10:00 AM
#4
Frenzied Member
Can't you do something to do with the try, catch and throw keywords?
-
May 13th, 2002, 10:02 AM
#5
Thread Starter
Fanatic Member
to be honest i don't know what they are.
I am not the best javascript programmer in the world you see!!!
-
May 13th, 2002, 10:12 AM
#6
Frenzied Member
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.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
May 13th, 2002, 01:12 PM
#7
Addicted Member
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
-
May 13th, 2002, 01:31 PM
#8
Frenzied Member
Can you post you code so we can see where the problem is?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|