Throwing arbitrary exceptions is a bit of a problem since the type of the exception is determined at compile time. So if you want to store an exception and throw it some time later at a maybe unknown position in your code you must wrap it in an envelope and delegate the process of throwing to this wrapper.
Similar to the according Java classes they are called
Throwables
.
mockpp provides several classes and functions to deal with single or lists of throwables
as well as creating them from ordinary values.
ThrowableItem it (make_throwable(float(1.234))); it.get()->throw_me(); ThrowableList lit; lit.push_back(make_throwable(std::string("data"))); lit.push_back(make_throwable(unsigned(123))); lit.nextThrowableObject()->throw_me();