00001
00002
00003
00004
00005 #ifndef PLAYA_EXCEPTIONS_H
00006 #define PLAYA_EXCEPTIONS_H
00007
00008 #include "PlayaDefs.hpp"
00009 #include "PlayaDebug.hpp"
00010 #include "Teuchos_ConfigDefs.hpp"
00011 #include "Teuchos_Assert.hpp"
00012 #include <stdexcept>
00013
00014
00015
00016
00017
00018 #define PLAYA_ERROR7(msg) \
00019 { \
00020 Teuchos::TestForException_break(); \
00021 std::ostringstream omsg; \
00022 omsg << __FILE__ << ":" << __LINE__ << ": " \
00023 << ": " << msg; \
00024 throw Playa::RuntimeError(TEUCHOS_OSTRINGSTREAM_GET_C_STR(omsg)); \
00025 }
00026
00027 #define PLAYA_ERROR(msg) \
00028 { \
00029 std::ostringstream omsg; \
00030 omsg << __FILE__ << ":" << __LINE__ << ": " \
00031 << ": " << msg; \
00032 const std::string &omsgstr = omsg.str(); \
00033 Teuchos::TestForException_break(omsgstr); \
00034 throw Playa::RuntimeError(TEUCHOS_OSTRINGSTREAM_GET_C_STR(omsg)); \
00035 }
00036
00037
00038 #define PLAYA_TRACE(e) \
00039 { \
00040 std::ostringstream omsg; \
00041 omsg << e.what() << std::endl \
00042 << "caught in " << __FILE__ << ":" << __LINE__ << std::endl ; \
00043 throw Playa::RuntimeError(TEUCHOS_OSTRINGSTREAM_GET_C_STR(omsg)); \
00044 }
00045
00046 #define PLAYA_TRACE_MSG(e, msg) \
00047 { \
00048 std::ostringstream omsg; \
00049 omsg << e.what() << std::endl \
00050 << "caught in " << __FILE__ << ":" << __LINE__ << std::endl ; \
00051 omsg << msg << std::endl; \
00052 throw Playa::RuntimeError(TEUCHOS_OSTRINGSTREAM_GET_C_STR(omsg)); \
00053 }
00054
00055 #define PLAYA_BOUNDSCHECK(i, low, high, location) \
00056 { \
00057 TEUCHOS_TEST_FOR_EXCEPTION( i < low || i > high, Playa::RuntimeError, \
00058 "Bounds violation in " << location << ": " \
00059 << #i << "is out of range [" \
00060 << #low << ", " << #high << "]") \
00061 }
00062
00063 #define PLAYA_CHECK_ARRAY_SIZE_MATCH(a1, a2) \
00064 {\
00065 TEUCHOS_TEST_FOR_EXCEPTION(a1.size() != a2.size(), Playa::RuntimeError, \
00066 y "Mismatched array sizes: size(" << #a1 << ")=" << a1.size() \
00067 << " size(" << #a2 << ")=" << a2.size() << ". Expected equal sizes");\
00068 }
00069
00070
00071
00072 namespace Playa
00073 {
00074
00075
00076
00077
00078
00079
00080 class InternalError : public std::logic_error
00081 {
00082 public:
00083
00084 InternalError(const std::string& msg);
00085 };
00086
00087
00088
00089
00090
00091 class RuntimeError : public std::runtime_error
00092 {
00093 public:
00094
00095 RuntimeError(const std::string& msg);
00096 };
00097
00098 }
00099
00100
00101
00102 #endif