Logo ROOT   6.08/07
Reference Guide
TPyException.h
Go to the documentation of this file.
1 // @(#)root/pyroot:$Name: $:$Id$
2 // Author: Scott Snyder, Apr 2004
3 
4 #ifndef ROOT_TPyException
5 #define ROOT_TPyException
6 
7 //////////////////////////////////////////////////////////////////////////////
8 // //
9 // TPyException //
10 // //
11 // Purpose: A C++ exception class for throwing python exceptions //
12 // through C++ code. //
13 // Created: Apr, 2004, sss, from the version in D0's python_util. //
14 // //
15 // The situation is: //
16 // - We're calling ROOT C++ code from python. //
17 // - The C++ code can call back to python. //
18 // - What to do then if the python callback throws an exception? //
19 // //
20 // We need to get the control flow back to where PyROOT makes the ROOT call.//
21 // To do that we throw a TPyException. //
22 // We can then catch this exception when we do the ROOT call. //
23 // //
24 // Note that we don't need to save any state in the exception -- it's //
25 // already in the python error info variables. //
26 // (??? Actually, if the program is multithreaded, this is dangerous //
27 // if the code has released and reacquired the lock along the call chain. //
28 // Punt on this for now, though.) //
29 // //
30 //////////////////////////////////////////////////////////////////////////////
31 
32 // ROOT
33 #ifndef ROOT_DllImport
34 #include "DllImport.h"
35 #endif
36 #ifndef ROOT_Rtypes
37 #include "Rtypes.h"
38 #endif
39 
40 // Standard
41 #include <exception>
42 
43 
44 namespace PyROOT {
45 
46 class TPyException : public std::exception {
47 public:
48 // default constructor
49  TPyException();
50 
51 // destructor
52  virtual ~TPyException() throw();
53 
54 // give reason for raised exception
55  virtual const char* what() const throw();
56 
57  ClassDef(TPyException,0) //C++ exception for throwing python exceptions
58 };
59 
60 } // namespace PyROOT
61 
62 #if defined(G__DICTIONARY) && defined(R__SOLARIS)
63 // Force the inclusion of rw/math.h
64 #include <limits>
65 // Work around interaction between a struct named exception in math.h,
66 // std::exception and the use of using namespace std;
67 #if (__SUNPRO_CC < 0x5050)
68 #define exception std::exception
69 #endif
70 #endif
71 #endif
virtual const char * what() const
#define ClassDef(name, id)
Definition: Rtypes.h:254