Suppose I have the following construct:
Public Sub SomeMethod() Try doSomething() Catch ex as Exception handleException(ex) End Try End Sub
And I would like to write handleException (ex). Suppose my class has different event handling options:
Public Enum ExceptionHandlingType DisplayInMessageBox 'Display in msgbox ThrowToCaller 'Raise the error to the caller routine RaiseOnMessageEvent 'e-mail End Enum
Below I tried to write "handleException". It seems that no matter what I do, if the object was set in Exception "ThrowToCaller" mode, then the stack trace gets all messed up when I use handleException (). How can I just get a clean stack trace when the option is "ThrowToCaller" (every other option seems to work fine)
Public Sub handleException(ex as Exception) Select Case mExceptionHandling Case ExceptionHandlingType.DisplayInMessageBox MsgBox(ex.Message) Case ExceptionHandlingType.ThrowToCaller Throw New Exception(ex.Message, ex) Case ExceptionHandlingType.RaiseOnMessageEvent SendEMailMessage(ex) End Select End Sub
Denis source share