【发布时间】:2012-07-12 09:46:42
【问题描述】:
我正在维护一些似乎不会在停止语句上停止的 VB 代码。
当我在特定条件下运行程序时,此代码从最后一行代码抛出 System.Exception("Timed out")。
但是,如果您逐行查看代码,似乎它永远无法达到此语句。首先它尝试返回 MyBase.Save。如果不能,那么它会点击 stop 语句并停止。
但似乎程序只是跳过了停止语句。
如何调试此代码?具体来说,它如何跳过停止语句到达语句 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
【问题讨论】: