Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Handling.... what do you guys normally do?

Status
Not open for further replies.

elziko

Programmer
Nov 7, 2000
486
GB
I have a function that runs a load of SQL commands in a database. However if anything goes wrong I have an error function that returns the database's record back to its original state. This is fine but what happens if the error handling function also creates an error? Is it possible to detect an error in the error handling function and then do something else (ie. give up and show a warning that the situatiuon cannot be remedied).

Whats the best thing to do here? Or is what I'm trying to do a bad idea?

Any help? Thanks,

elziko
 
I always use the 'on error goto' and then write my error handler at the bottom of the sub. When I wan't to create my own errors I use the err.raise command which takes the program to the error handler. In this way the program will never shuts down due to an error.
 
I tend to follow sunaj's strategy -- but not always...

I sometimes do this:

on error resume next
i=ubound(array_that_might_be_empty())
if err.number <> 0 then
' do something....
endif
on error goto My_Error_Handler

It depends on what type of error I'm trying to detect and which style is the most natural way to deal with it. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Bascially I was being lazy I was using an error handler that will handle every error in one go and if it couldnt just quit. But now I'm acounting for every type of error and acting accordingly so its not an issue anymore.

Thanks

elziko
 
While developing, it is always better to comment out the On Error Resume Next or ON ERROR GOTO xyz

Because only then you can locate where the error occurs, especially if the code is too big.


RR.
 
Always i catch the errors and find it's error no. and error description of vb
(using on error go to statement & err.no & err.description)
& then accordingly flashes my own message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top