Re: Exceptions as return values

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Alan Pretre wrote:
> Being nitpicky...
>
> User exceptions should derive from System.ApplicationException, not
> System.Exception. See the Remarks section here in MSDN:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemapplicationexceptionclasstopic.asp
>
> To wit:
> "This exception is provided as means to differentiate between exceptions
> defined by applications versus exceptions defined by the system."

However, look at this:

http://blogs.msdn.com/brada/archive/2004/03/25/96251.aspx
quoting the .NET Framework Standard Library Annotated Reference Vol 1:

<quote>
KC - Designing exception hierarchies is tricky. Well-designed exception
hierarchies are wide, not very deep, and contain only those exceptions
for which there is a programmatic scenario for catching. We added
ApplicationException thinking it would add value by grouping exceptions
declared outside of the .NET Framework, but there is no scenario for
catching ApplicationException and it only adds unnecessary depth to the
hierarchy.

JR - You should not define new exception classes derived from
Application-
Exception; use Exception instead. In addition, you should not write
code that
catches ApplicationException.
</quote>

Jon

.



Relevant Pages

  • Re: Inheriting from ApplicationException - Taboo? Jeffrey Richter says so...
    ... It does have a point, I never catch the ApplicationException, either catch ... the particular exception I'm interested or Exception, ... > "Designing exception hierarchies is tricky. ... > which there is a programmatic scenario for catching. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Need help with ApplicationException
    ... Yes there is a "userid name" variable in the employee object. ... I am not sure why I am using ApplicationException instead of Exception. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Inheriting from ApplicationException - Taboo? Jeffrey Richter says so...
    ... that APplicationException was a mistake. ... See the ".Net Framework Standard ... You can see an excerpt of it with the ApplicationException annotations here: ... "Designing exception hierarchies is tricky. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Exceptions in Business Classes
    ... application exception class is some future change they will make. ... > using ApplicationException. ... > an ApplicationException any differently than the base Exception class. ... > recent post in Brad Abrams' blog points this out ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Inheriting from ApplicationException - Taboo? Jeffrey Richter says so...
    ... ApplicationException, in fact I think that FxCOP has a rule that check this ... also it has a rule saying that you should not catch Exception. ... the existing Directory and File classes in FCL can ... > should I "anger the saints" and inherit from ApplicationException? ...
    (microsoft.public.dotnet.languages.csharp)