|
-
Jan 28th, 2000, 06:53 AM
#1
Thread Starter
New Member
Hi there!
I'm writing an error handler that let's the user (and eventually the programmer) know what function was processing when the error occurred. The error message includes:
- form name
- function name
- error description
So, for form, I can use me.name (form name)
For the error, I can use err.description (description of error).
But how do write the function name (without having to hardcode the function name each time)????
Here's a little code if that makes it clearer?
CODE:
Exit Sub
error:
If ProcessError(Err, Me.Name, "UpdateControls") = vbYes Then
Resume Next
End If
So, instead of writing "UpdateControls" or whatever my function name is, I'd like a way to automatically fill it in.
Thank you very, very much!!
Andrea 
-
Jan 28th, 2000, 07:37 AM
#2
Frenzied Member
Well, this is a simple (but probably non-professional) way to solve the problem...use a property proceedure!
Create a property called "CurrentProceedure" that holds the name of the most recent proceedure executed.
The drawback is that the first line of each function must assign the function name to the property, but it WOULD enable cutting and pasting of your error handler without manually typing in the function name each time, i.e:
If ProcessError (Err, Me.Name, Me.CurrentFunction) = vbYes Then
Resume Next
-
Jan 28th, 2000, 07:41 AM
#3
There isn't any way. What I do is to code the declaration of my common error routine this way: Public Sub DisplayError(sRoutine As String) and in each routine that has an error handler I do
Code:
ErrorRoutine:
If Err.Number <> 0 Then DisplayError "CalcDiskType"
where "CalcDiskType" is the procedure name. It's really not a lot of effort to do that.
------------------
Marty
COGITO EGGO SUM
I think; therefore I am a waffle.
-
Jan 28th, 2000, 07:41 AM
#4
Frenzied Member
P.S. I sure misspelled procedure a lot! Also, if the procedure is called "CurrentProcedure", then my example should have read:
If ProcessError (Err, Me.Name, Me.CurrentProcedure) = vbYes Then
Resume Next
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
|