HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyExceptionState.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 
8 #include "pxr/pxr.h"
9 #include "pxr/base/tf/api.h"
10 #include "pxr/external/boost/python/handle.hpp"
11 
12 #include <string>
13 
15 
17  TfPyExceptionState(pxr_boost::python::handle<> const &type,
18  pxr_boost::python::handle<> const &value,
19  pxr_boost::python::handle<> const &trace) :
20  _type(type), _value(value), _trace(trace) {}
21 
22  TF_API
24 
25  TF_API
27 
28  TF_API
30 
31  // Extract Python's current exception state as by PyErr_Fetch() and return
32  // it in a TfPyExceptionState. This leaves Python's current exception state
33  // clear.
34  TF_API
35  static TfPyExceptionState Fetch();
36 
37  pxr_boost::python::handle<> const &GetType() const { return _type; }
38  pxr_boost::python::handle<> const &GetValue() const { return _value; }
39  pxr_boost::python::handle<> const &GetTrace() const { return _trace; }
40 
41  // Move this object's exception state into Python's current exception state,
42  // as by PyErr_Restore(). This leaves this object's exception state clear.
43  TF_API
44  void Restore();
45 
46  // Format a Python traceback for the exception state held by this object, as
47  // by traceback.format_exception().
48  TF_API
49  std::string GetExceptionString() const;
50 
51 private:
52  pxr_boost::python::handle<> _type, _value, _trace;
53 };
54 
pxr_boost::python::handle const & GetValue() const
#define TF_API
Definition: api.h:23
GLsizei const GLfloat * value
Definition: glcorearb.h:824
TF_API ~TfPyExceptionState()
TF_API TfPyExceptionState & operator=(TfPyExceptionState const &)
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
static TF_API TfPyExceptionState Fetch()
TF_API std::string GetExceptionString() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
TF_API void Restore()
pxr_boost::python::handle const & GetTrace() const
TfPyExceptionState(pxr_boost::python::handle<> const &type, pxr_boost::python::handle<> const &value, pxr_boost::python::handle<> const &trace)
pxr_boost::python::handle const & GetType() const