As pointed out by others, boost :: exception is a good option. However, like all options that use the general approach of the base class, they rely on all thrown exceptions that are received from this base class. If your catch brokers need to add information to an exception from a third-party library, this will not work.
Perhaps for this it is enough to have intermediate catch handlers:
catch (std::exception& ex) { std::string msg = ex.what(); msg.append(" - my extra info"); ex = std::exception(msg.c_str());
This only works for std :: exception implementations that provide a constructor that accepts a string parameter (e.g. VC ++). The std :: exception constructor that takes a string is a non-standard extension.
source share