HepMC3 event record library
Public Member Functions | Private Attributes
error_already_set Class Reference

#include <pytypes.h>

+ Inheritance diagram for error_already_set:
+ Collaboration diagram for error_already_set:

Public Member Functions

 error_already_set ()
 
 error_already_set (const error_already_set &)=default
 
 error_already_set (error_already_set &&)=default
 
void restore ()
 
void discard_as_unraisable (object err_context)
 
void discard_as_unraisable (const char *err_context)
 
void clear ()
 
bool matches (handle exc) const
 
const objecttype () const
 
const objectvalue () const
 
const objecttrace () const
 

Private Attributes

object m_type
 
object m_value
 
object m_trace
 

Detailed Description

Fetch and hold an error which was already set in Python. An instance of this is typically thrown to propagate python-side errors back through C++ which can either be caught manually or else falls back to the function dispatcher (which then raises the captured error back to python).

Definition at line 324 of file pytypes.h.

Constructor & Destructor Documentation

error_already_set ( )
inline

Constructs a new exception from the current Python error indicator, if any. The current Python error indicator will be cleared.

Definition at line 328 of file pytypes.h.

Member Function Documentation

void discard_as_unraisable ( object  err_context)
inline

If it is impossible to raise the currently-held error, such as in destructor, we can write it out using Python's unraisable hook (sys.unraisablehook). The error context should be some object whose repr() helps identify the location of the error. Python already knows the type and value of the error, so there is no need to repeat that. For example, func could be helpful. After this call, the current object no longer stores the error variables, and neither does Python.

Definition at line 348 of file pytypes.h.

References handle::ptr().

bool matches ( handle  exc) const
inline

Check if the currently trapped error type matches the given Python exception class (or a subclass thereof). May also be passed a tuple to search for any exception class matches in the given tuple.

Definition at line 363 of file pytypes.h.

References handle::ptr().

void restore ( )
inline

Give the currently-held error back to Python, if any. If there is currently a Python error already set it is cleared first. After this call, the current object no longer stores the error variables (but the .what() string is still available).

Definition at line 340 of file pytypes.h.


The documentation for this class was generated from the following files: