Why is it a bad idea to throw your own exceptions?
Answers were Sorted based on User's Feedback
Answer / supratim sengupta
Actually throwing your own exceptions is an excellent way
to handle various exceptions the way you want it to handle.
You can centralize the whole exception handling. It could
be useful in product development where you might miss out
some exception conditions and then you can always write a
common custom exception handler that can shoot you an email
with all the details of the exception.
| Is This Answer Correct ? | 8 Yes | 1 No |
Answer / guest
Not necessarily. If you're writing a library of code to be
used by other clients you don't always know the right thing
to do if an exceptional problem comes up. So it isn't always
a bad idea to throw your own exceptions.
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / guest
Well, if at that point you know that an error has occurred,
then why not write the proper code to handle that error
instead of passing a new Exception object to the catch
block? Throwing your own exceptions signifies some design
flaws in the project.
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / japan shha
Perhaps what you meant to ask was "When is it not necessarily a good idea to throw my own exception?"
http://stackoverflow.com/questions/2215112/why-is-it-a-bad-idea-to-throw-your-own-exceptions
| Is This Answer Correct ? | 0 Yes | 0 No |
Explain the Usage of web.config
What are predicates in c#?
How to transpose rows into columns and columns into rows in a multi-dimensional array?
How to make a class not inheritable other than sealed?
What are the benefits of using windows services:
What is access modifier in c#?
How can we set the class to be inherited, but prevent the method from being over-ridden?
What is the difference while using directive vs using statement ?
How many digits is a 32 bit number?
Where do we use serialization in c#?
Can you override private virtual methods?
What is the difference between returning iqueryable vs ienumerable?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)