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.
- Difference between Multilevel Queue (MLQ) and Multi Level Feedback Queue (MLFQ) CPU scheduling algorithms
- Catch and Throw Exception In Ruby
- Debugging and Testing of a Node Application
- C# | Exception
- C# | Array IndexOutofRange Exception
- Scala | Exception Handling
- Exception Handling in Node
- Exception Handling in C#
- Why does canvas.toDataURL() throws a security exception?
- Exception Handling in Kotlin with Examples
- Exception handling in Julia
- Node.js | First Application
- What is RAC(Real Application Cluster)?
- How to auto-save data when application is offline in Angular 8?
- What is SPA (Single page application) in AngularJS?
- AngularJS | Application
- Unit Testing of Node.js Application
- Difference between node.js require and ES6 import and export
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.