22#include <boost/python/extract.hpp>
23#include <boost/python/handle.hpp>
24#include <boost/python/object.hpp>
33 PyObject *ptype, *pvalue, *ptraceback;
34 PyErr_Fetch(&ptype, &pvalue, &ptraceback);
35 PyErr_NormalizeException(&ptype, &pvalue, &ptraceback);
37 py::handle<> handle_type(ptype);
38 py::handle<> handle_value(pvalue);
39 py::handle<> handle_traceback(py::allow_null(ptraceback));
42 py::object err_msg_obj(py::handle<>(PyObject_Str(pvalue)));
43 m_error_msg = py::extract<std::string>(err_msg_obj);
45 py::object err_repr_obj(py::handle<>(PyObject_Repr(pvalue)));
46 m_error_msg = py::extract<std::string>(err_repr_obj);
51 py::object traceback(handle_traceback);
54 loc.
lineno = py::extract<long>(traceback.attr(
"tb_lineno"));
55 loc.
filename = py::extract<std::string>(traceback.attr(
"tb_frame").attr(
"f_code").attr(
"co_filename"));
56 loc.
funcname = py::extract<std::string>(traceback.attr(
"tb_frame").attr(
"f_code").attr(
"co_name"));
60 traceback = traceback.attr(
"tb_next");
75 msg <<
"File \"" << trace.filename <<
"\", line " << trace.lineno <<
", in " << trace.funcname;
static Elements::Logging logger
Logger.
void log(log4cpp::Priority::Value level, const std::string &logMessage)
std::list< Location > m_traceback
const std::list< Location > & getTraceback() const
const Exception & log(log4cpp::Priority::Value level, Elements::Logging &logger) const
Log error message and traceback.
boost::variant< bool, int64_t, double, AttributeSet > Value