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 Level exception.

System 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 Exception:

  • 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.


My Personal Notes arrow_drop_up

Student at Padre Conceicao College of Engineering, Goa Computer Engineering

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.