Structured Exception Handling in .NET Part 4: Re-Throwing Exceptions

This entry is part of a series, Structured Exception Handling in .NET»

Sometimes when you have caught an Exception, you want to do a bit of processing and then throw the Exception on again, or perhaps check the Message property to decide if you can handle it, and if you can’t then you throw it again. This is actually quite easy – you just use Throw, with no parameters.

eg.

Try
   DoSomething()
Catch Ex as Exception
   If Ex.Message="Connection Failed"
      Conn.Reconnect()
   Else
      Throw
   End If
End Try

One thing that you really don’t want to do is to Throw Ex

No related posts.

Tags: , ,

Leave a Reply