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 options of handling events:
Public Enum ExceptionHandlingType
DisplayInMessageBox 'Display in msgbox
ThrowToCaller 'Raise the error to the caller routine
RaiseOnMessageEvent 'e-mail
End Enum
Below is my attempt at writing "handleException". It seems no matter what I do, if the object was set with Exception mode of "ThrowToCaller" then the stack trace gets all messed up when I use handleException(). How can I just have a clean stack trace generated when the option is "ThrowToCaller" (every other option seems like it is working 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