From 96e155e5f8ac8cc66a54d525b2c8463b730e30b5 Mon Sep 17 00:00:00 2001 From: Adam Wendt Date: Fri, 11 Nov 2022 15:33:23 -0700 Subject: Add python support for error_context Added ledger.session.error_context() to py_session.cc to get the error context message when exceptions are thrown. --- src/py_session.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/py_session.cc b/src/py_session.cc index 16acd0e8..b948997c 100644 --- a/src/py_session.cc +++ b/src/py_session.cc @@ -33,6 +33,7 @@ #include "pyinterp.h" #include "pyutils.h" +#include "error.h" #include "session.h" namespace ledger { @@ -49,6 +50,11 @@ namespace { { return python_session->read_journal_from_string(data); } + + PyObject* py_error_context(const session_t& session) + { + return str_to_py_unicode(error_context()); + } } void export_session() @@ -63,6 +69,7 @@ void export_session() .def("close_journal_files", &session_t::close_journal_files) .def("journal", &session_t::get_journal, return_internal_reference<>()) + .def("error_context", &py_error_context) ; scope().attr("session") = -- cgit v1.2.3