Types of Errors occur during program development
It is common to occur any error during program development due to the ignorance of developer, program or some external resource. Basically, there are two types of errors occur during any program development. They are Compile time errors and Run-time errors. As their name saying, compile time errors occur at the time of compiling the source code while run-time errors occur at the time of executing the program.
Compile-time errors are two types, they are
Syntax Errors: occur when sentence construction rules are avoided.
Semantic Errors: occur when some useless code is founded.
Run-time Errors are also two types, they are
Logical Errors: occur due to ignorance or negligence of developer.
unExpected Errors: occur due to lack of or failure of some external resource.
Exception Handling of Python is a mechanism to handle unexpected runtime errors only (the last one), but not any other types of errors discussed above. Exception can be defined as an unwanted situation during the execution of the program. Exception causes the abnormal termination of the program. This situation is not suitable for the following examples real-time scenarios
- ATM program is closed due to wrong password entry by a user.
- A network application is closed due to some mistake done by the user on a particular node.
Handling of exception is the concept of avoiding abnormal termination of the program due to exception so that the program would continue its execution by taking necessary steps regarding exception. The handling of exception is not providing solution for the exception but it is providing an alternative way to run the rest of the program which is not dependent on the code in which exception occurred.