Exception handling

Answer Posted / alb.shah

"An exception handler is a piece of code which will be
called when an exception occurs."

.NET Framework provides several classes to work with
exceptions. The keywords try, catch are used to handle
exceptions in .NET. You have to put the code (that can
cause an exception) in a try block. If an exception occurs
at any line of code inside a try block, the control of
execution will be transfered to the code inside the catch
block.
If any statement within the try block raises an exception,
the control of execution will be transfered to the first
line within the catch block. You can write the error
handling code in the catch block, like recording the error
message into a log file, sending an email to the
administrator about the problem occurred, showing an
appropriate error message to the user etc.
You can optionally use a 'finally' block along with the try-
catch. The 'finally' block is guaranteed to be executed
even if there is an exception.
If an exception is not 'handled' in code, the application
will crash and user will see an ugly message. Instead, you
can catch the exception, log the errors and show a friendly
message to the user.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which property needs to be set for script manager control to extend the time before throwing time out expection if no response is received from the server?

729


What is the use of placeholder control? Can we see it at runtime?

807


What is Razor View Engine

821


Why we use asp.net for website development?

686


Define reflection in .net?

750


What’s the use of “GLOBAL.ASAX” file?

823


Is data edited in the Repeater control?

789


What is session and cookies in asp.net?

742


What are ASHX files?

797


i want the asp.net technical questions and answeres

1796


what is command line compiler.what are the steps and how it is related to debugging.

1612


Do gac'ed assemblies have fulltrust?

846


Is asp.net 64-bit enabled? How?

808


What is the difference between trace and debug in asp.net?

832


What are the components of ado.net?

711