Josh Mcfarlane wrote:
I keep trying to get myself out of the return-code mindset, but it
doesn't seem to work. They are suppose to get rid of if-then statements
of return codes, but you still have to do an if statement once the code
leaves your control (3rd party libraries, OS functions, etc) to throw
an exception?
Does anyone have any good suggestions on a book or website that deals
with exception handling that could help turn this poor mind off of
return codes? =)
Thanks,
Josh McFarlane
Like, get with the '90s dude! ;)
Exception handling in C++ has been one of the hardest adjustments for me to
make while coming from Java to C++. It's hard to use exceptions well in
C++; to a large extent because the other guy doesn't do it well,
consistently, or at all. In addition, there is much more flexibility (than
in Java) in what is actually thrown, how it is caught (by reference, or by
value), how it is (or can be) processed, and in using exception
specifications.
As for a source on exception handling, there is Stroustrup's tome,
TC++PL(SE). It is exhaustive in its discussion of exception handling.
That's not exactly the same as saying it is helpful.
For me, one consistent difficulty is to understand what the various types of
std::exception derivatives really mean. For instance. what are the
differences between std::out_of_range, std::range_error and
std::length_error? Sure, I can look it up when I need to know, but I
rarely remember the subtleties when I want to use one of these. That makes
using them time consuming.
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell