ALERT

[FREE DEMO] Deploy Your Enterprise Cloud in Minutes

Exception Handling

Definition - What does Exception Handling mean?

Exception handling is a mechanism in which a programming construct is used to consistently trap, intercept and handle the error occurred during application execution. The Common Language Runtime (CLR) of .NET Framework is designed to use an exception handling model based on exception objects and protected blocks of code.

The features of exception handling mechanism implemented in CLR are as follows:

a) Each language can have its own specification for handling exceptions without any restrictions

b) Exceptions are generated and handled irrespective of the language used and type of code (managed or unmanaged)

c) Exceptions can be thrown across process or machine boundaries

Techopedia explains Exception Handling

.NET runtime throws exceptions as objects derived from System.Exception class that contain error details, including message and line of code where the error occurred, etc. The construct "try..catch..finally" is used for exception handling. While "try" (where exceptions are anticipated) and “catch” (where exceptions are handled) blocks are mandatory, the "finally" (where code executed in any case) block is optional.

When compared to error handling implemented using traditional methods - like usage of return code as in Component Object Model (COM) and "go to" statements, as in Visual Basic, etc. - the main benefits of exceptions in .NET are trapping of all failures, elimination of process of checking return value and its usage (if invalid) in applications, usage in scenarios where there is no return value such as constructors, increased reliability and better performance.

While Java provides "checked" exceptions that help in preventing incidence of unhandled exceptions during compilation, they cannot be used for errors which are unrecoverable failure. Exception handling in C++ differs from that in .NET by not having the "finally" block for cleaning up resources and without any restriction for the type of exception.

This definition was written in the context of .NET

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
"Techopedia" on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Resources
The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.