7 #ifndef IGLOO_EXCEPTIONS_H 8 #define IGLOO_EXCEPTIONS_H 14 template <
typename ExceptionType>
18 static std::auto_ptr<ExceptionType>& last_exception()
20 static std::auto_ptr<ExceptionType> last;
24 void compiler_thinks_i_am_unused() {}
28 last_exception().reset(NULL);
32 template <
typename ExceptionType>
33 inline ExceptionType& LastException()
37 Assert::Failure(
"No exception was stored");
44 #define IGLOO_CONCAT2(a, b) a##b 45 #define IGLOO_CONCAT(a, b) IGLOO_CONCAT2(a, b) 47 #define AssertThrows(EXCEPTION_TYPE, METHOD) \ 48 ExceptionStorage<EXCEPTION_TYPE> IGLOO_CONCAT(IGLOO_storage_, __LINE__); IGLOO_CONCAT(IGLOO_storage_, __LINE__).compiler_thinks_i_am_unused(); \ 50 bool wrong_exception = false; \ 51 bool no_exception = false; \ 55 no_exception = true; \ 57 catch (const EXCEPTION_TYPE& e) \ 59 ExceptionStorage<EXCEPTION_TYPE>::last_exception() = std::auto_ptr<EXCEPTION_TYPE>(new EXCEPTION_TYPE(e)); \ 63 wrong_exception = true; \ 67 std::ostringstream stm; \ 68 stm << "Expected " << #EXCEPTION_TYPE << ". No exception was thrown."; \ 69 Assert::Failure(stm.str()); \ 73 std::ostringstream stm; \ 74 stm << "Expected " << #EXCEPTION_TYPE << ". Wrong exception was thrown."; \ 75 Assert::Failure(stm.str()); \
Definition: exceptions.h:15