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.
- C# | Exception
- Scala | Exception Handling
- C# | Array IndexOutofRange Exception
- Exception Handling in Node
- How to adjust CSS for specific zoom level?
- Debugging and Testing of a Node Application
- System Software
- Functions of Operating System
- Type System Unification in C# .NET
- C# | How to retrieve the system's reference to the specified String
- How to get the value of System Property and Environment Variable in Java?
- How Specify Length and Width of Square Grid Picture System in Bootstrap?
- What is the difference between GUI and CUI?
- Difference between “!==” and “==!” in PHP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.