Teuchos_StandardCatchMacros.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef TEUCHOS_STANDARD_CATCH_MACROS_HPP
00030 #define TEUCHOS_STANDARD_CATCH_MACROS_HPP
00031
00032 #include "Teuchos_GlobalMPISession.hpp"
00033 #include "Teuchos_FancyOStream.hpp"
00034 #include "Teuchos_TypeNameTraits.hpp"
00035
00057 #define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE,ERR_STREAM,SUCCESS_FLAG) \
00058 catch( const std::exception &excpt ) { \
00059 if((VERBOSE)) { \
00060 std::ostringstream oss; \
00061 oss \
00062 << "\np="<<::Teuchos::GlobalMPISession::getRank()<<": *** Caught standard std::exception of type \'" \
00063 <<Teuchos::typeName(excpt)<<"\' :\n\n"; \
00064 Teuchos::OSTab(oss).o() << excpt.what() << std::endl; \
00065 std::cout << std::flush; \
00066 (ERR_STREAM) << oss.str(); \
00067 (SUCCESS_FLAG) = false; \
00068 } \
00069 } \
00070 catch( const int &excpt_code ) { \
00071 if((VERBOSE)) { \
00072 std::ostringstream oss; \
00073 oss \
00074 << "\np="<<::Teuchos::GlobalMPISession::getRank() \
00075 << ": *** Caught an integer std::exception with value = " \
00076 << excpt_code << std::endl; \
00077 std::cout << std::flush; \
00078 (ERR_STREAM) << oss.str(); \
00079 (SUCCESS_FLAG) = false; \
00080 } \
00081 } \
00082 catch( ... ) { \
00083 if((VERBOSE)) { \
00084 std::ostringstream oss; \
00085 oss << "\np="<<::Teuchos::GlobalMPISession::getRank()<<": *** Caught an unknown exception\n"; \
00086 std::cout << std::flush; \
00087 (ERR_STREAM) << oss.str(); \
00088 (SUCCESS_FLAG) = false; \
00089 } \
00090 }
00091
00092 #endif // TEUCHOS_STANDARD_CATCH_MACROS_HPP