Exception Handling Mechanism



When we write and execute in our code in .NET, there is possibility of three types of error occurrence
1)    Syntactical errors
2)    Compilation errors
3)    Runtime errors
1) Syntactical Errors
  • These errors occur by typing wrong syntax like, missing double quotes, terminators, typing wrong spelling for keywords etc.
  • Programmer can identify these errors, while writing the code and can be rectified
  • These errors do not cause any harm to the program execution
2)Compilation Errors
  • These errors occur when the program is compiled
  • These errors are like, assigning wrong data to a variable, trying to create object for abstract class or Interface etc
  • These errors can be identified by the programmer and can be rectified, before execution of the program only.
  • These errors do not cause any harm to the program execution
 3)Run Time Errors
  • These errors will occur at the time of executing the program
  • These errors are like… entering wrong data into a variable trying to open a file for which there is no permission, trying to connect to database with wrong user id and password etc.
 Exception
  • A runtime error is known as Exception
  • Exception can’t be identified and rectified by the programmer
  • Exceptions will cause abnormal termination of the program execution
  • So, to avoid abnormal termination of  the program execution, we need to handle the exceptions
Methods to Handle Exception

There are three methods to handle the except
  1.  Logical Implementation
  2.  Try catch Implementation
  3. On error go to implementation

No comments:

Post a Comment