Try Catch When

Quite frankly, I didn’t knew that there’s even a WHEN clause to the TRY-CATCH block. Thanks to Eric Porter for sharing this tip!

Public Shared Function SaveChangesToServer(ByVal ShouldThrowException As Boolean) As Boolean
               ' Do some stuff
          Catch Ex As Exception When ShouldThrowException
               Throw Ex
          End Try
     Return Success
End Function
Show Comments