Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
Pyston::Exception Class Reference

#include <Exceptions.h>

Inheritance diagram for Pyston::Exception:
Inheritance graph
[legend]
Collaboration diagram for Pyston::Exception:
Collaboration graph
[legend]

Classes

struct  Location
 Traceback location. More...
 

Public Member Functions

 Exception ()
 
const std::list< Location > & getTraceback () const
 
const Exceptionlog (log4cpp::Priority::Value level, Elements::Logging &logger) const
 Log error message and traceback.
 
void restore () const
 Call PyErr_Restore and restore the error. This can be used when Pyston::Exception goes back to Python.
 
- Public Member Functions inherited from Elements::Exception
 Exception (ExitCode e=ExitCode::NOT_OK)
 
 Exception (const char *message, ExitCode e=ExitCode::NOT_OK)
 
 Exception (const std::string &message, ExitCode e=ExitCode::NOT_OK)
 
 Exception (const char *stringFormat, Args &&... args)
 
virtual ~Exception () noexcept=default
 
const char * what () const noexcept override
 
ExitCode exitCode () const noexcept
 
void appendMessage (const T &message)
 
- Public Member Functions inherited from std::exception
what (T... args)
 
~exception (T... args)
 
operator= (T... args)
 
exception (T... args)
 

Private Attributes

std::list< Locationm_traceback
 
boost::python::object m_error_type
 
boost::python::object m_error_value
 
boost::python::object m_error_traceback
 

Additional Inherited Members

- Protected Attributes inherited from Elements::Exception
std::string m_error_msg
 
const ExitCode m_exit_code
 

Detailed Description

Exception class Used to wrap Python exceptions so the caller code can handle them transparently

Definition at line 33 of file Exceptions.h.

Constructor & Destructor Documentation

◆ Exception()

Pyston::Exception::Exception ( )

Constructor The error message is retrieved from the exception thrown inside Python

Note
If there is no error set on the Python side, a generic error will be used instead
The constructor will take care of calling PyErr_clear
Warning
The caller is assumed to own the global interlock!

Definition at line 30 of file Exceptions.cpp.

References std::string::empty(), Pyston::Exception::Location::filename, Pyston::Exception::Location::funcname, Pyston::Exception::Location::lineno, Elements::Exception::m_error_msg, m_error_traceback, m_error_type, m_error_value, and m_traceback.

Here is the call graph for this function:

Member Function Documentation

◆ getTraceback()

auto Pyston::Exception::getTraceback ( ) const
Returns
Error traceback

Definition at line 66 of file Exceptions.cpp.

References m_traceback.

◆ log()

const Exception & Pyston::Exception::log ( log4cpp::Priority::Value  level,
Elements::Logging logger 
) const

Log error message and traceback.

Definition at line 70 of file Exceptions.cpp.

References Elements::Logging::log(), logger, m_traceback, and std::stringstream::str().

Here is the call graph for this function:

◆ restore()

void Pyston::Exception::restore ( ) const

Call PyErr_Restore and restore the error. This can be used when Pyston::Exception goes back to Python.

Definition at line 79 of file Exceptions.cpp.

References m_error_traceback, m_error_type, and m_error_value.

Member Data Documentation

◆ m_error_traceback

boost::python::object Pyston::Exception::m_error_traceback
private

Definition at line 66 of file Exceptions.h.

Referenced by Exception(), and restore().

◆ m_error_type

boost::python::object Pyston::Exception::m_error_type
private

Definition at line 64 of file Exceptions.h.

Referenced by Exception(), and restore().

◆ m_error_value

boost::python::object Pyston::Exception::m_error_value
private

Definition at line 65 of file Exceptions.h.

Referenced by Exception(), and restore().

◆ m_traceback

std::list<Location> Pyston::Exception::m_traceback
private

Definition at line 63 of file Exceptions.h.

Referenced by Exception(), getTraceback(), and log().


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