1 #ifndef TUT_EXCEPTION_H_GUARD
2 #define TUT_EXCEPTION_H_GUARD
5 #include "tut_result.hpp"
11 * The base for all TUT exceptions.
13 struct tut_error : public std::exception
15 explicit tut_error(const std::string& msg)
20 virtual test_result::result_type result() const
22 return test_result::ex;
25 virtual std::string type() const
27 return "tut::tut_error";
30 const char* what() const throw()
32 return err_msg.c_str();
40 void operator=(const tut_error &);
42 const std::string err_msg;
46 * Group not found exception.
48 struct no_such_group : public tut_error
50 explicit no_such_group(const std::string& grp)
55 virtual std::string type() const
57 return "tut::no_such_group";
60 ~no_such_group() throw()
66 * Test not found exception.
68 struct no_such_test : public tut_error
70 explicit no_such_test(const std::string& grp)
75 virtual std::string type() const
77 return "tut::no_such_test";
80 ~no_such_test() throw()
86 * Internal exception to be throwed when
87 * test constructor has failed.
89 struct bad_ctor : public tut_error
91 explicit bad_ctor(const std::string& msg)
96 test_result::result_type result() const
98 return test_result::ex_ctor;
101 virtual std::string type() const
103 return "tut::bad_ctor";
112 * Exception to be throwed when ensure() fails or fail() called.
114 struct failure : public tut_error
116 explicit failure(const std::string& msg)
121 test_result::result_type result() const
123 return test_result::fail;
126 virtual std::string type() const
128 return "tut::failure";
137 * Exception to be throwed when test desctructor throwed an exception.
139 struct warning : public tut_error
141 explicit warning(const std::string& msg)
146 test_result::result_type result() const
148 return test_result::warn;
151 virtual std::string type() const
153 return "tut::warning";
162 * Exception to be throwed when test issued SEH (Win32)
164 struct seh : public tut_error
166 explicit seh(const std::string& msg)
171 virtual test_result::result_type result() const
173 return test_result::term;
176 virtual std::string type() const
187 * Exception to be throwed when child processes fail.
189 struct rethrown : public failure
191 explicit rethrown(const test_result &result)
192 : failure(result.message), tr(result)
196 virtual test_result::result_type result() const
198 return test_result::rethrown;
201 virtual std::string type() const
203 return "tut::rethrown";
210 const test_result tr;
213 struct skipped : public tut_error
215 explicit skipped(const std::string& msg)
220 virtual test_result::result_type result() const
222 return test_result::skipped;
225 virtual std::string type() const
227 return "tut::skipped";