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
- Exception Handling in C#
- Scala | Exception Handling
- Exception Handling in Node
- C# | Array IndexOutofRange Exception
- Catch and Throw Exception In Ruby
- Why does canvas.toDataURL() throws a security exception?
- How to adjust CSS for specific zoom level?
- Level Ordering of Factors in R Programming
- Node.js | First Application
- What is RAC(Real Application Cluster)?
- Debugging and Testing of a Node Application
- How to auto-save data when application is offline in Angular 8?
- System Software
- Node.js | File System
- Functions of Operating System
- How to Get Local IP Address of System using PHP ?
- Type System Unification in C# .NET
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.