- Local time
- Today, 03:24
- Joined
- Feb 28, 2001
- Messages
- 30,126
In my current project, I have some situations where I want to pass an error back to the program that activates my routines. I know how to raise an error but the error causes a trap in the Class Module when I want the error to show up in the caller / user of the class module. I have On Error traps in the caller, so some of the online advice I saw doesn't seem to apply. The articles I found say the error will be passed up the call-frame stack until a declared handler is currently inactive but eligible to take the error at which time it will trap there.
The articles further suggest that I can get the desired effect by placing an error trap in the Class Module and have that handler re-raise the error before doing a Resume Next. But what actually happens is that it traps in the Class Object code.
Is there a trick to sending that error back up the line and NOT taking it in the Class Object?
Here is a sample:
The behavior is that when the error is triggered, the trap occurs in the ErrHand routine when I want it occur in the thing that called this Property Let routine.
The articles further suggest that I can get the desired effect by placing an error trap in the Class Module and have that handler re-raise the error before doing a Resume Next. But what actually happens is that it traps in the Class Object code.
Is there a trick to sending that error back up the line and NOT taking it in the Class Object?
Here is a sample:
Code:
Public Property Let SourceLine(TheLine As String)
'
' prepare for parsing by loading up a string. string can contain up to several thousand characters.
' once all is reset, we are ready to actually load things up
' measure line size, reset error code. Token class-code is reset by Class_Reset call.
'
On Error GoTo ErrHand
If IsNull(TheLine) Then
cbERR = True
ceErrCode = PRSERR_INVAL_USE_OF_NULL
Err.Raise ceErrCode, TypeName(Me), XLateErrCode(ceErrCode)
Else
Call Class_Reset 'erase all remnants. resets almost everything.
csClause = TheLine 'load up the string
clCLength = Len(csClause) 'set the internal line length
cbEOL = False 'new line so not at EOL yet
cbERR = False 'and give benefit of the doubt at first
ccTCCode = tclNoCls 'no parse has yet occurred so mark consistent with that fact
ceErrCode = PRSERR_NO_ERROR 'no errors at the moment
csPosPnt = "" 'no error pointer
End If
Exit Property
ErrHand:
Err.Raise Err.Number, TypeName(Me), XLateErrCode(Err.Number)
Resume Next
End Property
The behavior is that when the error is triggered, the trap occurs in the ErrHand routine when I want it occur in the thing that called this Property Let routine.