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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically Discovering Error Source 2

Status
Not open for further replies.

boggg1

Programmer
Oct 17, 2002
102
EU
I trap the errors occuring on my user's systems and record err.number etc. in a file so that my programs can be improved. But I would also like to record the subroutine/function and/or module where the error occured. Is there is a way of programmatically discovering which subroutine (or function) and/or module where the error occured in VB ?

Boggg1
[bigglasses]
 
To do this, I declare one global variable, e.g.

strMyProcName

I then place a line at the start of each procedure / function etc:

Code:
strMyProcname = "Name of procedure"

The global variable can then be written to the error log with other information.

One advantage of this, is that I can create multiple instances of this line in a large procedure, if I am trying to find the point in the procedure where an error is occurring:

Code:
strMyProcname = "LargeProcedure Step 1"

etc.

I hope that this helps.


Bob Stubbs
 
Yeah, that would work. I was thinking of something a whole lot more sophisticated. It will mean an awesome amount of editing of my huge program but simpler = best sometimes. Have a star.

Thanks.

Boggg1
[bigglasses]
 
Check this out


Version 4.51 for VB 6 is the best one to use.

This will allow you to automatically add error handling to your application, puts in procedures names and gives call stacks. There is even code to handle displying the errors to the user within the addin.

Also useful in it is the ability to add line numbers to the code to get to the exact line causing problems.

Regards,

Hammy
 
The editing can be done programatically. See the ubiquitous {F1} (aka HELP). A topic to start w/ is "procedureLines" or, perhaps, "bodyLines" or even "lines".





MichaelRed


 
I think automatically adding error checking would be too difficult in my case as I already have a sophisticated error trapping scheme. But thanks for the input anyway, I might use this in future when I start something new.

The basic method is the same in each reply, so I know if I want it I have a lot of work to do. Thanks guys, again. Have a star hammy.

Boggg1
[bigglasses]
 
Take a look at the addin mztools at you can create error handling templates with predefined variables such as:{PROCEDURE_NAME}
{PROCEDURE_TYPE}
{MODULE_NAME}






Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top