Public Member Functions | Private Attributes | List of all members
error_already_set Class Reference

#include <pytypes.h>

Inheritance diagram for error_already_set:
Inheritance graph
[legend]

Public Member Functions

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

Private Attributes

object m_trace
 
object m_type
 
object m_value
 

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::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.

error_already_set::error_already_set ( const error_already_set )
default
error_already_set::error_already_set ( error_already_set &&  )
default
error_already_set::~error_already_set ( )
inlineoverride

Definition at line 2105 of file pybind11.h.

Member Function Documentation

void error_already_set::clear ( void  )
inline

Definition at line 358 of file pytypes.h.

void error_already_set::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.

void error_already_set::discard_as_unraisable ( const char *  err_context)
inline

Definition at line 352 of file pytypes.h.

bool error_already_set::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.

void error_already_set::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.

const object& error_already_set::trace ( ) const
inline

Definition at line 367 of file pytypes.h.

const object& error_already_set::type ( ) const
inline

Definition at line 365 of file pytypes.h.

const object& error_already_set::value ( ) const
inline

Definition at line 366 of file pytypes.h.

Member Data Documentation

object error_already_set::m_trace
private

Definition at line 370 of file pytypes.h.

object error_already_set::m_type
private

Definition at line 370 of file pytypes.h.

object error_already_set::m_value
private

Definition at line 370 of file pytypes.h.


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


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:51:47