I am maintaining some VB code that does not seem to stop on a stop statement.
When I run the program under certain conditions, this code throws the System.Exception(“Timed out”) from the last line of code.
But if you go thru the code line-by-line, it seems like it can never hit this statement. First it tries to Return MyBase.Save. If it can’t, then it will hits the stop statement and stop.
But it seems like the program is just skipping the stop statement.
How can I debug this code? Specifically, how does it skip the stop statement to get to the statement Throw New System.Exception(“Timed out”)
Public Overrides Function Save() As Uber
If IsDeleted AndAlso Not CanDeleteObject() Then
Throw New System.Security.SecurityException("User is not authorized to remove a Uber")
ElseIf IsNew AndAlso Not CanAddObject() Then
Throw New System.Security.SecurityException("User is not authorized to add a Uber")
ElseIf Not IsNew AndAlso Not CanEditObject() Then
Throw New System.Security.SecurityException("User is not authorized to update a Uber")
End If
Try
Return MyBase.Save
Catch ex As Exception
Stop //why is the code not stopping here?
End Try
Throw New System.Exception("Timed out") //this line executes, but I don't see how the code gets there
End Function
I think Stop only creates a breakpoint for debugging.
The execution of the code will continue.
I think an exception is being thrown in Return MyBase.Save. It’s being caught in the Catch block but it is effectively being ignored by that block because ex is never used.