Alter line number of Error
- From: Steve <sredmyer@xxxxxxxxxx>
- Date: Tue, 10 Jul 2007 05:40:48 -0700
Ok I know this sounds really strange but I need to change the line
number reported by ERL. Here is the situation. I have an ActiveX dll
(which I can not change) that handles errors by returning an error
object. Then in my app I must check the functions return for an Error
object and if it exists then raise the error so that standard
application error handling can be used.
For example:
Private ThisSub()
Dim objErr As ErrObject
Dim lngErr as Long
5 On Error Goto ErrorHandler
10 Set objErr = MyObject.SomeFunc(Param1, Param2)
15 If objErr Is Nothing Then lngErr = 0 Else lngErr = objErr.Number
20 If lngErr = 0 then
25 'Do work here...
30 Else
35 'Raise the error here so that apps error handling can be
used
40 Err.Raise objErr.Number, objErr.Source, objErr.Description
45 End if
50 Exit Sub
ErrorHandler:
MsgBox Err.Description & (" error number " & Err.Number & ")
occured at " & Erl
End Sub
In the above example, if an error occured in the call to
MyObject.SomeFunc, the error reporting would indicate that the error
happened on line 40 when infact it happened on line 10. So aside from
this type of error managament being ugly (atleast to me), it also does
not report the actual line where the error occured.
I realize that in this simple example the problem does not appear to
be much of an issue but in real code, where the routines are larger
and considerably more complex, the true cause of an error is less
obvious. I also realize that I could simply hard code the line number
since the Err.Raise will always be raising an error from the call to
SomeFunc. However this is an app which is constantly having mods done
and the routines are being constantly renumbered (as changes are made)
so this solution also presents a bit of a maintenance issue.
What I would like to be able to do is to set the value of Erl just
prior to the call to the ActiveX function. While this is still not an
ideal solution (Erl values would still need to be maintained) at least
the Erl value is managed right at the point of possible error and not
(possibly) many lines away where the error is actually handled.
Anybody got any ideas on how I might do this
Thanks,
Steve
.
- Follow-Ups:
- Re: Alter line number of Error
- From: Steve
- Re: Alter line number of Error
- From: Steve Gerrard
- Re: Alter line number of Error
- From: Larry Serflaten
- Re: Alter line number of Error
- Prev by Date: Re: Open, Close, & Freefile
- Next by Date: Re: Urgent. please!
- Previous by thread: Re: Best approach for broadcasting a notifivation to another program?
- Next by thread: Re: Alter line number of Error
- Index(es):
Relevant Pages
|