Defines | |
| #define | TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg) |
| Macro for throwing an exception with breakpointing to ease debugging. | |
| #define | TEST_FOR_EXCEPT(throw_exception_test) TEST_FOR_EXCEPTION(throw_exception_test,std::logic_error,"Error!") |
This macro is designed to be a short version of TEST_FOR_EXCEPTION() that is easier to call. | |
Functions | |
| void | TestForException_break () |
| The only purpose for this function is to set a breakpoint. | |
|
|
Value: { \
const bool throw_exception = (throw_exception_test); \
if(throw_exception) { \
TestForException_break(); \
TeuchosOStringStream omsg; \
omsg << __FILE__ << ":" << __LINE__ << ": " \
<< #throw_exception_test << ": " << msg; \
throw Exception(TEUCHOS_OSTRINGSTREAM_GET_C_STR(omsg)); \
} \
}
my_source_file.cpp that the exception std::out_of_range is thrown if n > 100. To use the macro, the source code would contain (at line 225 for instance):
TEST_FOR_EXCEPTION( n > 100, std::out_of_range
, "Error, n = " << n << is bad" );
n = 125 > 100 for instance, the std::out_of_range exception would be thrown with the error message: /home/bob/project/src/my_source_file.cpp:225: n > 100: Error, n = 125 is bad
In order to debug this, simply open your debugger (gdb for instance), set a break point at TEST_FOR_EXCEPTION( obj1->val() > obj2->val(), std::logic_error, "Oh no!" ); double obj1_val = obj1->val(), obj2_val = obj2->val(); TEST_FOR_EXCEPTION( obj1_val > obj2_val, std::logic_error, "Oh no!" );
As an alternative, you can set a breakpoint for any exception thrown by setting a breakpoint in the function Definition at line 108 of file Teuchos_TestForException.hpp. |
|
|
This macro is designed to be a short version of
Definition at line 131 of file Teuchos_TestForException.hpp. |
|
|
The only purpose for this function is to set a breakpoint.
Definition at line 31 of file Teuchos_TestForException.cpp. |
1.3.9.1