![]() When an exceptionoccurs, the CLR will find the nearest Try block and pass control to thefollowing associated exception-handling blocks.īecause Catch blocks are evaluated in the order that they occur inyour code, you must always place the most specific exceptions first if you havemultiple Catch blocks. ![]() Exceptions raised cause theCLR to search for the nearest Try block (which may be nested within oneanother) and then pass control to the following Catch block or on tothe Finally block if no Catch block is present in thecode.Ī Try block in its most basic form looks like this: Try ' Code that may cause an exceptionCatch ' Code that handles any exceptionEnd TryĪny normal code may be placed within the Try block, including another Tryblock or calls to methods including Try blocks of their own. When code is processed that may generate an exception, the code may be placedwithin a Try block, which must in turn be followed by one or more Catch blocks or a Finally block. Everything betweenthe Try and End Try keywords is part of a single error-handlingunit. You may not have intervening code separating these blockswhen configuring event-handling solutions within your code. The Try, Catch, and Finally blocks must be consecutivewithin code.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |