Is there any way to get the actual line number that an error occurs on in conjunction with the Throw statement? Here is a sample:
VB Code:
Private Sub TestErrors() Try Dim i As Integer i = 5 i *= 3 CreateError(i) Catch ex As Exception DisplayException(ex) End Try End Sub Private Sub CreateError(ByVal i As Integer) Try Dim n As Integer n = CInt(i / n) Catch ex As Exception Throw ex End Try End Sub
In this example, the error stack will report lines 11 and 28 as the error line numbers. I really want to know that line 25 is the "real" root of the error and that line 28 is just where the error was thrown. If I were to handle the exception rather than use a throw, then the stack would report line 25. The problem is, that I need to use throw in many of my objects to allow the calling application to handle exceptions. Any ideas or thoughts?




Reply With Quote