Logo ROOT   6.16/01
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#include "DllImport.h"
34#include "Rtypes.h"
35
36// Standard
37#include <exception>
38
39
40namespace PyROOT {
41
42class TPyException : public std::exception {
43public:
44// default constructor
46
47// destructor
48 virtual ~TPyException() noexcept;
49
50// give reason for raised exception
51 virtual const char* what() const noexcept;
52
53 ClassDef(TPyException,0) //C++ exception for throwing python exceptions
54};
55
56} // namespace PyROOT
57
58#if defined(G__DICTIONARY) && defined(R__SOLARIS)
59// Force the inclusion of rw/math.h
60#include <limits>
61// Work around interaction between a struct named exception in math.h,
62// std::exception and the use of using namespace std;
63#if (__SUNPRO_CC < 0x5050)
64#define exception std::exception
65#endif
66#endif
67#endif
#define ClassDef(name, id)
Definition: Rtypes.h:324
virtual ~TPyException() noexcept
virtual const char * what() const noexcept