answersLogoWhite

0


Best Answer

The idiomatic way to express error conditions in .NET framework is by throwing exceptions. In C#, we can handle them using the try-catch-finally statement:

try

{

// code which can throw exceptions

}

catch

{

// code executed only if exception was thrown

}

finally

{

// code executed whether an exception was thrown or not

}

Whenever an exception is thrown inside the try block, the execution continues in the catch block. The finallyblock executes after the try block has successfully completed. It also executes when exiting the catch block, either successfully or with an exception.

In the catch block, we usually need information about the exception we are handling. To grab it, we use the following syntax:

catch (Exception e)

{

// code can access exception details in variable e

}

The type used (Exception in our case), specifies which exceptions will be caught by the catch block (all in our case, as Exception is the base type of all exceptions).

Any exceptions that are not of the given type or its descendants, will fall through.

We can even add multiple catch blocks to a single try block. In this case, the exception will be caught by the first catch block with matching exception type:

catch (FileNotFoundException e)

{

// code will only handle FileNotFoundException

}

catch (Exception e)

{

// code will handle all the other exceptions

}

This allows us to handle different types of exceptions in different ways. We can recover from expected exceptions in a very specific way, for example:

  • If a user selected a non-existing or invalid file, we can allow him to select a different file or cancel the action.
  • If a network operation timed out, we can retry it or invite the user to check his network connectivity.

For remaining unexpected exceptions, e.g. a NullReferenceExceptions caused by a bug in the code, we can show the user a generic error message, giving him an option to report the error, or log the error automatically without user intervention.

User Avatar

Wiki User

6y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is meant by error handling support in dot net?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is meant by dot -3 brake oil what is full form of DOT?

DOT, department of transportation.


What is the angle in which the dot product of two non zero vectors is equal?

It depends on what the dot product is meant to be equal to.


What is the name of this song i recently heard it on a advert and some of the lyrics are when you never say things that were meant to be said we will never know dot dot dot?

heppy


Why error using dot each function?

if the object you're trying to use .each on isn't an array, you'll encounter an error.


How many language support dot net?

44


Word gets the error File conversion Macros dot Select the encoding that makes your document readable?

whay not open error file in word ! help me please


Which agency serves as the Emergency Support Function coordinator?

Department of Transportation (DOT)


What was written in Morse Code on the the Green Monster?

the yawkeys initials is the answer that was posted, but it is wrong. It was meant to be the Yawkeys' ' initials but they made a mistake and it has never been corrected. On the left vertical side of the American League section, they correctly spell out in morse code the initials of Tom Yawkey which are TAY. In morse code that is dash (space) dot dash (space) dash dot dash dash. But on the right side (reading down) they meant to spell out JRY for Jeans intials but they made a spacing error. It should have read dot dash dash dash (space) dot dash dot (space) dash dot dash dash. However, they incorrectly inserted a space in what should have been the second letter, R. What should have read dot dash dot with a space after it, was incorrectly written as dot dash (then the incorrect space) and then a single dot (which is the letter E. The last letter, Y, was correct as dash dot dash dash. This resulted in changing the R to two letters, namely A and E, so the whole thing reads JAEY. Why this has never been caught for all these years is a mystery. Update: The initials have now been corrected! This happened sometime between 2006 and 2012 (I have compared a photo from 2006 which has the error and 2012 which has it corrected). Link to photo from 2012 with the correct code http://img.geocaching.com/cache/large/1e59c604-4dfe-475a-bbd8-cb02942d706d.jpg


What is the most common cause for a server application unvailable error on a website?

One of the most common reasons for getting a server application unavailable error is mixing dot NET framework. The error usually shows up when the Application Pool does not start.


Does packard bell dot s support minecraft?

No.It's to slow, and poor graphics card.


Why do you keep getting a 404 Not Found Error when you try to register or sign in to an account on Answerbag dot com?

This is not answerbag.com. You need to ask them.


Who created the division sign?

Division:It was first used in a algebra book called " Teutshe algebra" in 1659. The author was a man named Johann Rahn.It was meant as a nmonic device as a dot-line-dot. The dot being a general term then the logic term, a vertical line 'to separate' followed by another general term, a dot.