Difference between System Level Exception and Application Level Exception in C#
An exception is an unwanted or unexpected event, which occurs during the execution of a program i.e at runtime, that 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 may crash or show an unexpected event during its runtime execution. This unwanted event is known as Exception and is generally gives the indication regarding something wrong within the code. In C# an exception can be a System
or an Application
System Level Exception:
Application Level Exception:
- System exceptions are derived from the base class System.SystemException which in itself is a derived class of SystemException.
- A System Exception occurs when a fatal or non-recoverable error is encountered, like a database crash, bound errors etc.
- Application-level exceptions are derived from the base class System.ApplicationException which is also a derived class of SystemException.
- An Application-level exception occurs when a recoverable error is encountered, for example, the wrong type of input data, arithmetic exceptions etc.
- These are user-defined exceptions thrown by the application and mostly the program can resume back to its ordinary course of instructions after solving this type exception.
- In any typical application, Exceptions are generally handled at the code level using try-catch blocks. If the code does not have a try and catch block for the occurred exception then it propagates to the page level, at page level the Page_Error routine can be used to handle the exception. If the error is still not handled at the page level then the error finally propagates to the Application level.
- At the application level, we use the global.aspx file to overwrite Application_Error.
Share your thoughts in the comments
Please Login to comment...