VB6 Cumulitive Error Handling

powerman

Gawd
Joined
May 21, 2002
Messages
562
I have a very large project with thousands fof lines of code. I would like to develop an error handling system for it. I know how to create an error handler for each sub, but I wanted to make something that would handle any sub so I can copy and paste it into my many functions and subs.

Is it possible to get the name of the current function or sub? I'd like to do something like this:

On error goto ErrorHandler


Exit Sub

ErrorHandler:
Open App.path & "\Error.txt" for Append as #1

Write #1, Now
Write #1, "$Sub Name$"
Write #1, err.Number, Err.Description

I'd like to be able to just copy that to each sub since my code is so long. The sub the error occured in would make debugging so much easier. Has anyone done anything like this? I know I could create a constant to hold the sub name and change it for every sub but that would take a lot of time. Thanks for the help.
 
There isn't a way to get the current sub name. Sorry.

For shits and giggles though, if you use line numbers you can use Erl to get the line number of the error message.
 
Back
Top