DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 620 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

1
kicks
submitted by BlackWasp 1 year, 4 months ago

blackwasp.co.uk — The thirty-fifth part of the C# Fundamentals tutorial completes an investigation of exception handling. In this article we will consider the throwing of exceptions to report error conditions. This includes the use of standard and custom exception types.

Add a comment 3 comments | category: | Views: 37 | Get KickIt image code
tags: , | tag it

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:

Comments:
Eh. Very basic; also, extending the ApplicationException object or any other exception type other than System.Exception is considered bad practice in general. Custom exceptions should almost always extend System.Exception because if you extend any other exception type you risk callers catching your exception unintentionally when they catch your chosen base type. In this code, if you had a caller that was catching ApplicationException, they would (possibly) unintentionally catch your exception type. Only when you specifically want this kind of behavior is when you should extend a different base extension type other than System.Exception.
posted by yesthatmcgurk yesthatmcgurk 1 year, 4 months ago
An interesting comment, thank you. The article is supposed to be basic, it is a part of a large tutorial for beginners.

When I wrote this one I serious pondered over the extension of System.Exception or ApplicationException. SOME people consider it bad practice to extend ApplicationException. Indeed this is written about in the personal blog of at least one person at Microsoft. This is usually to keep the exception hierarchy flat. However, Microsoft also suggest within their own C# documentation that you should not extend the System.Exception. A case of one company giving to opposing views. In the end, I believe that both methods can be appropriate and that extending the ApplicationException to disassociate application-thrown rather than system-thrown exceptions is valid.
posted by BlackWasp 1 year, 4 months ago
I have now added a final paragraph to the article regarding this. It is interesting to note that when you read the MSDN topic that their advice is different for differenct .NET versions.
posted by BlackWasp 1 year, 2 months ago



information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads via The Lounge