|
||||
File indexing completed on 2025-01-30 10:21:53
0001 #ifndef CPYCPPYY_PYEXCEPTION_H 0002 #define CPYCPPYY_PYEXCEPTION_H 0003 0004 ////////////////////////////////////////////////////////////////////////////// 0005 // // 0006 // PyException // 0007 // // 0008 // Purpose: A C++ exception class for throwing python exceptions // 0009 // through C++ code. // 0010 // Created: Apr, 2004, Scott Snyder, from the version in D0's python_util. // 0011 // // 0012 // The situation is: // 0013 // - We're calling C++ code from python. // 0014 // - The C++ code can call back to python. // 0015 // - What to do then if the python callback throws an exception? // 0016 // // 0017 // We need to get the control flow back to where CPyCppyy calls C++. // 0018 // To do that we throw a TPyException. // 0019 // We can then catch this exception when we do the C++ call. // 0020 // // 0021 // Note that we don't need to save any state in the exception -- it's // 0022 // already in the python error info variables. // 0023 // (??? Actually, if the program is multithreaded, this is dangerous // 0024 // if the code has released and reacquired the lock along the call chain. // 0025 // Punt on this for now, though.) // 0026 // // 0027 ////////////////////////////////////////////////////////////////////////////// 0028 0029 // Standard 0030 #include <exception> 0031 #include <string> 0032 0033 // Bindings 0034 #include "CPyCppyy/CommonDefs.h" 0035 0036 0037 namespace CPyCppyy { 0038 0039 class CPYCPPYY_CLASS_EXTERN PyException : public std::exception { 0040 public: 0041 PyException(); 0042 virtual ~PyException() noexcept; 0043 0044 // give reason for raised exception 0045 virtual const char* what() const noexcept; 0046 0047 // clear Python error, to allow full error handling C++ side 0048 void clear() const noexcept; 0049 0050 private: 0051 std::string fMsg; 0052 }; 0053 0054 } // namespace CPyCppyy 0055 0056 #endif // !CPYCPPYY_PYEXCEPTION_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |