Visual Basic .NET/Exception handling
There are two main ways to handle errors in code.
The older method is "unstructured" error handling, available via the ON ERROR...GOTO syntax. This is still useful in certain circumstances where you wish to RESUME processing after handling the error.
"Structure error handling" is available with the newer Try...Catch...Finally syntax. Various error conditions are implemented via inheritors of the base Exception class.
HINT: If you wish to re-throw an exception inside a Catch block, use the Throw keyword without any arguments (particularly, do not use "Throw ex"). The Throw keyword resets the .StackTrace property of the exception object if an argument is supplied. Throw, without any arguments inside a Catch block will re-throw the error without resetting the .StackTrace property.