Boost logo

Boost :

From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2006-07-05 12:30:25

Dean Michael Berris wrote:

> On 7/5/06, Peter Dimov <pdimov_at_[hidden]> wrote:
>> But the whole point is that in some scenarios you want to catch T,
>> not exception_info. You are interested in a read_error and have an
>> appropriate response to it ready, but the rest of the exceptions
>> must be propagated unharmed.
>> So you catch( read_error const & r ) and use dynamic_cast to see
>> whether it also contains exception_info.
> Now I get it.
> Is there any other way of doing it than dynamic_cast'ing the
> exception then?

You need the dynamic_cast, because all you have is a read_error pointer, and
you need an exception_info pointer *if* it is available. For one reason or
another, the program could throw a "naked" read_error object (as opposed to
using throw failed<read_error>()) and in this case you will not have an
exception_info sub-object in the exception.

The reason why I have not hidden the dynamic_cast in a function
get_exception_info() is that the only implementation possible is through a
dynamic_cast, so why bother.


Boost list run by bdawes at, gregod at, cpdaniel at, john at