Inheriting from System.Exception or System.ApplicationException?

Posted in .NET quirks at Monday, December 17, 2007 6:02 PM UTC
Yes, there is a bit of confusion about this (also read this post).

I understand that the right way to create your application specific exceptions classes is to inherit from Exception class:
public class MyCustomEx : System.Exception{
   //class implementation
}
And if in any case you have to throw a general application exception that has not specific type, throw a System.ApplicationException:
throw new System.ApplicationException("Error retrieving data. The web service may be down");

kick it on DotNetKicks.com AddThis Social Bookmark Button

Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, em, i, strike, strong) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview

On this page...

Tags

Calendar

<July 2008>
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

Navigation

Archives

Recommended .NET blogs

The author

Iván Loire
Iván Loire (Zaragoza, Spain)

View Ivan Loire's profile on LinkedIn
Microsoft Certified Trainer
Send mail to the author(s) E-mail

Syndication

Feed Icon