|
-
Jan 5th, 2009, 11:46 AM
#1
Complex DB connection failure handling
I'm connecting to a DB on a server. Sometimes connection closes due to some reasons that really aren't important here.
I have some sort of a global error handling routine that is called from almost all error handlers.
When performing simple procedures that are using the connection and ARE NOT calling any other procedures that also use it, there's no problem. Code breaks, error handling routine is called and everything is OK.
But... when performing more complex procedures that are using the connection and are calling other procedures that also use it, sometimes code breaks in second level procedures (it depends when connection closes). My problem is that in this case first level procedures don't break. They continue working and everything goes just terribly wrong.
I can think of some ways to fix this, but, are too complex since my project is... well, quite big.
Any1?
-
Jan 5th, 2009, 11:55 AM
#2
Re: Complex DB connection failure handling
Could you cite a sample code that illustrates your case?
-
Jan 5th, 2009, 12:19 PM
#3
Re: Complex DB connection failure handling
Here's some pseudo code:
Code:
procedure1
code
procedure2 call
code (it should break here also, but it doesn't)
procedure2
code
connection closes
code (breaks - OK)
-
Jan 5th, 2009, 12:24 PM
#4
Re: Complex DB connection failure handling
Since procedure2 handles the error when it returns to procedure1 the error could have been cleared already. How about returning a boolean with procedure2 to determine if it has successfully done what it is supposed to do before letting procedure1 proceed?
-
Jan 5th, 2009, 01:04 PM
#5
Re: Complex DB connection failure handling
I'm using this approach in few cases but not all. Applying this to a complete project could take me few days. Also, most of the "procedure2" procedures are functions and already return other things in other types.
-
Jan 5th, 2009, 01:10 PM
#6
Re: Complex DB connection failure handling
How about propagating back the error to the caller?
Code:
Private Sub Command1_Click()
On Error GoTo Command1_Click_Err
Test
Exit Sub
Command1_Click_Err:
MsgBox Err.Description
End Sub
Private Sub Test()
On Error GoTo ErrorHandler
Err.Raise 100, , "test"
Exit Sub
ErrorHandler:
MsgBox Err.Description
Err.Raise Err.Number, Err.Source, Err.Description
End Sub
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
|