An exception is an unexpected event, which occurs during the execution of a program at runtime, which disrupts the normal flow of the program’s instructions. Sometimes during the execution of the program, the user may face the possibility that the program also crashes and show an unexpected event during its runtime execution. This unwanted event is known as Exception and is generally gives the indication that there is something wrong within the code. All exceptions inherited from “SystemException” class which is the main parent class of all exceptions. In general Exceptions are of two types
- System Level Exception
- Application Level Exception
System Level Exception:
- A System Exception occurs when a fatal error is encountered, generally fatal error cannot be recovered because the operating system has encountered a condition which it cannot resolve.
- System exceptions are generated from the base class System.SystemException. All Exceptions are derived from derived base class named as SystemException.
- System level exceptions occurs when your DB or DB server crashes etc.
Application Level Exception
- An application level exception occurs when a recoverable error is encountered in your code like object reference or arithmetic error etc.
- Application level errors are derived from System.ApplicationException and further it is derived from SystemException which is the parent class of all exceptions.
- Application level exceptions can be generally handled at the code level using try-catch blocks.
- With in .Net applications we use the global.aspx file to overwrite application error in its event named Application_Error.