The Throw Keyword
In some situations you need to programmatically throw exceptions or you catch exceptions but do not want to handle them in the Catch
block that intercepted exceptions. Programmatically throwing exceptions can be accomplished via the Throw
keyword. For instance, the following line of code throws an ArgumentNullException
that usually occurs when a method receives a null argument:
Throw New ArgumentNullException
You often need to manually throw exceptions when they should be handled by another portion of code, also in another application. A typical example is when you develop class libraries. A class library must be as abstract as possible, so you cannot decide which actions to take when an exception ...
Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.