Prev Next Home
Slide 9 of 10
StoredException
class ExceptionCouldNotBeConverted: {};
class StoredException
private:
bool failed;
AutoThrowable exception;
public: StoredException: failed(false) {}
StoredException& operator=(TheExceptionBeingHandled e) {
failed = true;
exception = ConvertToThrowable(e); }
StoredException::Throw() {
//this is for Where You Can Throw
if (failed) {
failed = false;
AutoThrowable toThrow = exception;
//this is to prevent throwing a thing twice
//and assigment transfers ownership to local variable
//and memory is cleared
//and THUS we don't throw the same thing twice (or N)
if (toThrow.get() != 0) {
toThrow->Throw();
else {
throw ExceptionCouldNotBeConverted(); }
}


Prev Next Home
Slide 9 of 10