Tuesday 16 September 2003 — This is more than 21 years old. Be careful.
I had thought that this debate was long over, but the other day I found myself arguing the benefits of throwing exceptions vs. returning status codes. Since I had to go through the whole thing, I’ve written them up. Maybe this will help put the argument to rest: Exceptions vs. status returns
Comments
When you settle on the exception approach, the next debate is checked vs. unchecked exception. Java and C# made different choices in this case. There were a couple of recent discussions on this.
Follow my links: http://www.bobcongdon.com/blog/2003_08_01_congdon_archive.html
And don't forget the problem when you throw an exception in a d'tor whilst unwinding the stack due to another exception. Bjarne's advice: "don't do that"
Regarding throwing exceptions from destructors. Yeah, don't do that. It's really bad. Throwing exceptions from constructors in C++ can be very tough to handle too.
Also, exceptions should mostly be used for errors, exceptional cases. I've worked on projects where exceptions happen during normal processing. The code flow can get very, very messy. Also, multiply nested try/catch blocks in a single method ain't a lot of fun.
Add a comment: