Newbie question on error checking

R

rich

Hello,

I am fairly new to ASP code and need help with error checking within my
script.

Specifically, I need to check for 3 things:

1. Trap the error if the script cannot find or connect to Active Directory.
2. Trap the error if the script cannot find the requested FSM Group.
3. Trap the error if the required input file is missing or it cannot create
or edit the output file.

I have learned a little about using the Err Object (Err.number and
Err.description) but that is about it. Can anyone offer me any general
tips/tricks about how best to do this or point me to some good reference
material?

Thanks in advance,

Rich
 
C

Chi

When you make connections to Database its good practice to put them all
within a try / catch statement as follows...

Try
'Open connection and perform what you need don
Catch ex As Exception
'Write code here to catch any errors and perform anything
that you want to perform if the code hits an error.
(example...)
Dim strError as string = ex.Message 'This will write
the error to the strError
End Try

Dont forget to close connections. Look at MSDN for Try/Catch Statements if
you need further info. But I believe its the Try/Catch is what you are
looking for.
 
B

Bob Barrows [MVP]

This user is likely using vbscript in a .asp page, not VB.Net in a .aspx
page, given that he posted in a classic asp group and mentioned the vbscript
Err object.
 
B

Bob Barrows [MVP]

rich said:
Hello,

I am fairly new to ASP code and need help with error checking within
my script.

Specifically, I need to check for 3 things:

1. Trap the error if the script cannot find or connect to Active
Directory.
2. Trap the error if the script cannot find the requested FSM Group.
3. Trap the error if the required input file is missing or it cannot
create or edit the output file.

I have learned a little about using the Err Object (Err.number and
Err.description) but that is about it. Can anyone offer me any
general tips/tricks about how best to do this or point me to some
good reference material?
I somehow missed this question the first time around. Are you still here?

Actually, what you've learned is pretty much all there is for error-handling
in vbscript:

'turn on error-handling
on error resume next
'do something whose error you wish to trap
if err <> 0 then
'handle the error
end if
'turn off error-handling
on error goto 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top