base class for director exceptions */
| 3135 | |
| 3136 | /* base class for director exceptions */ |
| 3137 | class DirectorException { |
| 3138 | protected: |
| 3139 | std::string swig_msg; |
| 3140 | public: |
| 3141 | DirectorException(PyObject *error, const char* hdr ="", const char* msg ="") |
| 3142 | : swig_msg(hdr) |
| 3143 | { |
| 3144 | SWIG_PYTHON_THREAD_BEGIN_BLOCK; |
| 3145 | if (strlen(msg)) { |
| 3146 | swig_msg += " "; |
| 3147 | swig_msg += msg; |
| 3148 | } |
| 3149 | if (!PyErr_Occurred()) { |
| 3150 | PyErr_SetString(error, getMessage()); |
| 3151 | } |
| 3152 | SWIG_PYTHON_THREAD_END_BLOCK; |
| 3153 | } |
| 3154 | |
| 3155 | const char *getMessage() const |
| 3156 | { |
| 3157 | return swig_msg.c_str(); |
| 3158 | } |
| 3159 | |
| 3160 | static void raise(PyObject *error, const char *msg) |
| 3161 | { |
| 3162 | throw DirectorException(error, msg); |
| 3163 | } |
| 3164 | |
| 3165 | static void raise(const char *msg) |
| 3166 | { |
| 3167 | raise(PyExc_RuntimeError, msg); |
| 3168 | } |
| 3169 | }; |
| 3170 | |
| 3171 | /* unknown exception handler */ |
| 3172 | class UnknownExceptionHandler |