[C++-sig] Re: Hnadling Python exceptions in C++
David Abrahams
david.abrahams at rcn.com
Fri Jul 19 16:54:09 CEST 2002
From: "Berthold Höllmann" <hoel at germanlloyd.org>
> OK, after thinking a bit about such a facility here is my idea. It
> would be nice to have a C++ exception class that reads out PyErr_Fetch
> when instantiated and can be converted back into a Python exception if
> needed. I tried to start an implementation.
Hi Berthold,
Before posting an implementation, could you please explain the use-case
you're trying to cover, show the interface, and how it would be used?
> The attached code is
> untested, it is just posted to share the idea.
Please don't use tabs when posting code; as you can see they disappear.
schnipp-schnapp-to-you-too-ly y'rs,
dave
> except.hpp:
> --8<------------------------schnipp------------------------->8---
> #ifndef EXCEPT_BH20020719_H_
> #define EXCEPT_BH20020719_H_
>
> #include <Python.h>
> #include <string>
>
> namespace boost {
> namespace python {
> namespace Error {
> class PyErrHandler {
> public:
> PyErrHandler();
> virtual void printOn(std::ostream&) const;
> private:
> PyObject *stype, *svalue, *straceback;
> };
> std::ostream& operator<<(std::ostream& os,
> const PyErrHandler& el);
> }
> }
> }
>
> #endif // EXCEPT_BH20020719_H_
> --8<------------------------schnapp------------------------->8---
More information about the Cplusplus-sig
mailing list