thesleepylizard
Programmer
Hi,
I have a large VB6 program. I want to handle every error in every subroutine and event. So, whenever it crashes, it can call a public sub Handle_Any_Error which will calmly tell the user what's happened.
I've tried several methods. The obvious one is to edit every subroutine in the project so it contains:
This is the normal way of doing it. BUT. To write this into hundreds of subroutines really is not the best way to do it.
I have tried speedening up this process by using some rather cheeky code:
This is very cheeky. I can just grab the first 4 lines in the subroutine and copy them into the start of every other subroutine!
However, I really really wish there was some way to say "Whenever an error occurs, just call this sub rather than call the default error message", or at least some option somewhere.
I'm sure I'm not the only person who's wanted to globally handle all errors in a program! Does anyone else have any ideas about the most efficient (coding-wise) method of handling all errors?
Thanks for your time,
-Sleepy
I have a large VB6 program. I want to handle every error in every subroutine and event. So, whenever it crashes, it can call a public sub Handle_Any_Error which will calmly tell the user what's happened.
I've tried several methods. The obvious one is to edit every subroutine in the project so it contains:
Code:
Private Sub MySub
on error goto MySub_Err
'
'
'code that might crash
'
'
exit sub
Mysub_Err:
Handle_Any_Error ()
resume next
End Sub
This is the normal way of doing it. BUT. To write this into hundreds of subroutines really is not the best way to do it.
I have tried speedening up this process by using some rather cheeky code:
Code:
Private Sub MySub
On Error Goto Error_Handler
If False then
Error_Handler: Handle_Any_Error ()
end if
'
'
'code that might crash
'
'
End Sub
This is very cheeky. I can just grab the first 4 lines in the subroutine and copy them into the start of every other subroutine!
However, I really really wish there was some way to say "Whenever an error occurs, just call this sub rather than call the default error message", or at least some option somewhere.
I'm sure I'm not the only person who's wanted to globally handle all errors in a program! Does anyone else have any ideas about the most efficient (coding-wise) method of handling all errors?
Thanks for your time,
-Sleepy