Exception Handling

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Exception Handling as PDF for free.

More details

  • Words: 410
  • Pages: 5
EXCEPTION HANDLING 

  

Exceptions : These are the runtime errors which will occur when ever the user provides an invalid value at the runtime. Note : exceptions are not syntax or logical errors. Exception Handling  it is used to handle runtime errors. Exception Handling in VB.Net can be done using 2 methods  Unstructured Method.

Un Structured Exception Handling 



It supports skipping an error if occurs or it can also be handled using this method. On error resume next  when ever this statement is used as the initial line in any method if any error occurs at the runtime then the line which causes the error will be ignored and the system will parse or resume from next statement.

Unstructured method of handling errors: 

 





On error goto <error label> : when ever the above statement is used in the initial line then if any runtime errors occurs while processing the application,the pointer will be moved on to the error label block for handling those errors. Points to remember  If Unstructured method is used to handle the errors then it is mandatory to end the method definitions before the error label block. To terminate a procedure “exit sub” should be used,to terminate a function “exit function” should be used. Error label block should be always written as the last statements. To define the block error label:statements to handle the exceptions

Structured Exception Handling 





It can be used to handle the exceptions with the support of individual blocks in a structured manner. Syntax  try ‘Statements to execute Catch Variable as exception class ‘Statements to handle exception Finally ‘manditory statements end try The base class to work with exceptions is



 







A single try block can have any no of catch blocks defined for it. Try blocks can be nested. It is manditory to define at least one catch block for a single try block. Finally block is an optional block if used within a try block definition then the code written in that block will always be executed. A single try block can have zero or only one finally block defined for it When ever an exception occurs then if the try block is defined with more than one catch than each and every catch block is verified in a sequential order till it encounters with the valid catch block.

Related Documents

Exception Handling
November 2019 33
Exception Handling
November 2019 36
Exception Handling
June 2020 26
Exception Handling
June 2020 22