I have a class module with a Let function that raises a custom error an example is shown below
Private pValue As Double
Public Property Let Value(v As Double)
If v < 0 Then
Err.Raise vbObjectError + 1, "error source", "error description"
Else
pValue = v
End If
End Property
In another sub I call the class function on an object (Example) and raise the error by passing a value less than 0. In this same sub I have error handling set up to catch multiple errors based on the error numbers.
Sub TestSub()
Dim Example As Test
Set Example = New Test
On Error GoTo errorHandler
Example.Value = -1
On Error GoTo 0
Exit Sub
errorHandler:
MsgBox Err.Number & "," & Err.Description & " in " & Err.Source
End Sub
The message box prints out the correct error number but the description is the generic Method ~ of object ~ failed, and the source is the generic VBAProject. I'd really like it to print out the error message I gave to Err.Raise. Does anyone know what the issue is here? I have error handling set to break on unhandled errors.
The message displayed in the message box is:
Method 'Value' of object '_Test' failed
Edit: Updated the code to a full scenario where the problem occurs