Why is it a bad idea to throw your own exceptions?

Answers were Sorted based on User's Feedback



Why is it a bad idea to throw your own exceptions?..

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

Why is it a bad idea to throw your own exceptions?..

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

Why is it a bad idea to throw your own exceptions?..

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

Why is it a bad idea to throw your own exceptions?..

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

Post New Answer

More C Sharp Interview Questions

Will finally block get executed if the 1exception had not occurred?

3 Answers  


how to deplaoy a project in the system?

1 Answers  


What is whitespace in c#?

0 Answers  


How do I declare a pure virtual function in c#?

0 Answers  


Is c# an open source?

0 Answers  






In c# how to connect crystal report?

2 Answers  


About multi level and multiple inheritance how to achieve in .net ?

2 Answers   CTS, MMTS,


why C#.net doesnot support prcedures and why it supports structs,functions

1 Answers  


What are circular references?

0 Answers  


How do I get deterministic finalization in c#?

0 Answers  


Is inheritance possible in c sharp?

0 Answers  


What do you understand by 'access specifiers' in C#?

0 Answers   Genpact,


Categories