Reputation: 2329
Does anybody have best practices for exception handling ?
When searching the web I find a lot of best practices on a code level (don't catch general exceptions, don't rethrow new exceptions etc.) What I am looking for is best practises on a higher level, stuff like :
Any thoughts and help are greatly appreciated, thanks.
Upvotes: 14
Views: 6215
Reputation: 49629
@Ilya:
That is probably one of the worst article Joel has ever written (for those who haven't read the link, he is arguing "Exceptions considered harmful", so do not use them).
Joel has two problems with exceptions:
They are invisible in the source code.
They create too many possible exit points for a function.
Ned Batchelder has an excellent (and much longer) reply to Joel here. Joel has a short reply here, to which Ned replies again here.
Brad Abrams also has a very nice article on the value of exceptions here.
Upvotes: 6
Reputation: 11638
You could do a lot worse than look through the code and documentation for Microsoft's Exception Management Application Block. It's probably overkill for a lot of scenarios, but it's certainly comprehensive.
Upvotes: 0
Reputation: 44268
.NET Specific but definitely has some worthwhile info.
http://www.codeproject.com/KB/architecture/exceptionbestpractices.aspx
Upvotes: 3
Reputation: 1324417
I like also to distinguish between:
That is for me a clear way to separate:
Upvotes: 2