Exception Class: When to Derive from it, In C# (.Net)?
Posted
by IbrarMumtaz
on Stack Overflow
See other posts from Stack Overflow
or by IbrarMumtaz
Published on 2010-04-05T12:39:07Z
Indexed on
2010/04/05
12:43 UTC
Read the original article
Hit count: 315
I am continuing with my exam revision.
I have come across the usage of the Base Exception class and I have seen it on exam papers also.
My question is when do you derive from the Base Exception class?
I am of the impression if you want a custom class to throw an exception with more meaningful information, then you can create a custom exception class that contains the exact data that is representative of how your custom class is used and what scenario it is designed to be used for?
Why can't my custom exception class derive from 'ApplicationException' or 'SecurityException' or the base 'Exception' class?
I am of the impression that I should derive from the base Exception class and not the previous two.
My question second is, when would you derive from the other two??? Are there any clear-cut distinctions as to when you would derive from either one of these three? Assuming there are no others I have I have missed out?
Thanks, Ibrar
© Stack Overflow or respective owner