Prev Next Home
Slide 7 of 10
ConvertToThrowable
typedef std::vector ConverterList;
AutoThrowable ConvertToThrowable (TheExceptionBeingHandled exception, const ConvertList list TheConvertList()) {
for (ConverterList::const_reverse_iterator c = list.rbegin(); c != list.rend())
try {
return (*c) (exception) }
catch (...) {}
return AutoThrowAble() // could be another throw, but we don't want to throw an exception in code where we're trying to NOTE do that
We'll use info if it's a time we don't know about
Also there's a problem if the new failed... but hmm... not a lot to do about this either
Reverse iterators 'cause if you catch a base class before an inherited class, you would get a base - (this list needs to be ordered by inheritance)
You can also use this pattern to hide exceptions from routines that don't understand exceptions
Deep Fact: It tries a list of ways to turn the exception into The Thing You Want (a base throwable class) (or exceptions into strings for users)


Prev Next Home
Slide 7 of 10