diff options
author | Adam Wendt <thelsdj@gmail.com> | 2022-11-11 15:33:23 -0700 |
---|---|---|
committer | Martin Michlmayr <tbm@cyrius.com> | 2022-11-13 19:33:40 +0800 |
commit | 96e155e5f8ac8cc66a54d525b2c8463b730e30b5 (patch) | |
tree | c816f9c1919ede883d0ba61025c54d960a272716 /src/py_session.cc | |
parent | 6cf04c38d21150153cd636be1325b0b204797d06 (diff) | |
download | fork-ledger-96e155e5f8ac8cc66a54d525b2c8463b730e30b5.tar.gz fork-ledger-96e155e5f8ac8cc66a54d525b2c8463b730e30b5.tar.bz2 fork-ledger-96e155e5f8ac8cc66a54d525b2c8463b730e30b5.zip |
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.
Diffstat (limited to 'src/py_session.cc')
-rw-r--r-- | src/py_session.cc | 7 |
1 files changed, 7 insertions, 0 deletions
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") = |