
Robert Ramey wrote:
hmmm looks to me that my program is not losing the type.
Looks like you've rediscovered std::nested_exception? http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2559.htm This works but it supports a different (Java-like) style of exception handling. This same mindset has led to exception specifications - libraries have to only throw whatever is enumerated in their interface, so they are forced to wrap. With boost.exception, the high level catch still receives the original exception type, without needing to unwrap. It can then probe for further information if it likes, or it could ignore it (doesn't necessarily have to be rewritten as additional layers are inserted.) In other words: With wrapping: throw X catch X, throw Y(X) catch Y A new layer is inserted: throw X catch X, throw Y(X) catch Y, throw Z(Y) catch Z // this had to change With boost.exception throw X catch X, add info, rethrow X catch X Note how the final catch X doesn't need to change if another layer is inserted: throw X catch X, add info, rethrow X catch X, add info, rethrow X catch X