Inheriting from System.Exception or System.ApplicationException?(dotneat.net)
submitted by iloire(310) 4 years, 5 months ago
What do you do?
3 comments |category: ASP.NET |Views: 27 Tweet
tags: ASP.NET another
Add a live kick counter to your blog >>
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:
Simply copy and paste this HTML into your blog post.
posted by yesthatmcgurk(4063) 4 years, 5 months ago 0
So very very wrong. The article suggests THROWING an application exception, not inheriting as the title suggests. And as an application exception should crash the program (i.e., no catch should be attempted as the application cannot carry on in a safe manner), throwing them in improper circumstances can be harmful. Rule of thumb for exceptions: Throw exceptions only when your code has encountered an error and cannot continue. If an exception exists that applies, throw it (i.e., ArgumentNullException, InvalidOperationException) If one doesn't, create a custom exception that extends from System.Extension. If there is no possibility for recovering from your error (and you know this to a certainty) throw an application exception. Rule of thumb for catching exceptions: The lower you are in the call stack, the less likely you will be able to handle an exception. If you can't handle it, don't catch it. If you need to add context to an exception thrown by an internal-to-your-class routine, you should: catch, wrap in a new exception and throw that. It is better to crash your application than catch System.Exception. That's right, slacker.
Reply
posted by JudahGabriel(814) 4 years, 5 months ago 0
mcgurk said it all, and very well said might I add.
posted by bladefist(471) 4 years, 5 months ago 0
mcgurk, what your saying sounds logical, but since its not in a blog, there is no way it can be true. :)
All tags Your tags
Suggest a new category
dpeterson(1273)
Telerik(409)
fdub(381)
amit.jain(273)
BlackWasp(259)
RobertTheGrey(259)
jalpesh(252)
KodefuGuru(227)
KMillerr(226)
vijayst(223)