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
00030
00031 #ifndef SUNDANCE_EXCEPTIONS_H
00032 #define SUNDANCE_EXCEPTIONS_H
00033
00034 #include "SundanceDefs.hpp"
00035 #include "Teuchos_ConfigDefs.hpp"
00036 #include "Teuchos_TestForException.hpp"
00037 #include <stdexcept>
00038
00039 #ifndef DOXYGEN_DEVELOPER_ONLY
00040
00041
00042
00043
00044 #define SUNDANCE_ERROR7(msg) \
00045 { \
00046 TestForException_break(); \
00047 TeuchosOStringStream omsg; \
00048 omsg << __FILE__ << ":" << __LINE__ << ": " \
00049 << ": " << msg; \
00050 throw Sundance::RuntimeError(TEUCHOS_OSTRINGSTREAM_GET_C_STR(omsg)); \
00051 }
00052
00053 #define SUNDANCE_ERROR(msg) \
00054 { \
00055 TeuchosOStringStream omsg; \
00056 omsg << __FILE__ << ":" << __LINE__ << ": " \
00057 << ": " << msg; \
00058 const std::string &omsgstr = omsg.str(); \
00059 TestForException_break(omsgstr); \
00060 throw Sundance::RuntimeError(TEUCHOS_OSTRINGSTREAM_GET_C_STR(omsg)); \
00061 }
00062
00063
00064 #define SUNDANCE_TRACE(e) \
00065 { \
00066 TeuchosOStringStream omsg; \
00067 omsg << e.what() << std::endl \
00068 << "caught in " << __FILE__ << ":" << __LINE__ << std::endl ; \
00069 throw Sundance::RuntimeError(TEUCHOS_OSTRINGSTREAM_GET_C_STR(omsg)); \
00070 }
00071
00072 #define SUNDANCE_TRACE_MSG(e, msg) \
00073 { \
00074 TeuchosOStringStream omsg; \
00075 omsg << e.what() << std::endl \
00076 << "caught in " << __FILE__ << ":" << __LINE__ << std::endl ; \
00077 omsg << msg << std::endl; \
00078 throw Sundance::RuntimeError(TEUCHOS_OSTRINGSTREAM_GET_C_STR(omsg)); \
00079 }
00080
00081 #define SUNDANCE_BOUNDSCHECK(i, low, high, msg) \
00082 { \
00083 TEST_FOR_EXCEPTION( i < low || i > high, Sundance::RuntimeError, \
00084 "Bounds violation: " << #i << "is out of range [" \
00085 << #low << ", " << #high << "]") \
00086 }
00087
00088 #define SUNDANCE_CHECK_ARRAY_SIZE_MATCH(a1, a2) \
00089 {\
00090 TEST_FOR_EXCEPTION(a1.size() != a2.size(), Sundance::RuntimeError, \
00091 "Mismatched array sizes: size(" << #a1 << ")=" << a1.size() \
00092 << " size(" << #a2 << ")=" << a2.size() << ". Expected equal sizes");\
00093 }
00094
00095
00096
00097 namespace Sundance
00098 {
00099
00100
00101
00102
00103
00104
00105 class InternalError : public std::logic_error
00106 {
00107 public:
00108
00109 InternalError(const std::string& msg);
00110 };
00111
00112
00113
00114
00115
00116 class RuntimeError : public std::runtime_error
00117 {
00118 public:
00119
00120 RuntimeError(const std::string& msg);
00121 };
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 class BadSymbolicsError : public RuntimeError
00135 {
00136 public:
00137
00138 BadSymbolicsError(const std::string& msg);
00139 };
00140 }
00141
00142
00143 #endif
00144
00145
00146 #endif