Improve reporting of Python exceptions
This commit is contained in:
@@ -48,7 +48,7 @@ public:
|
||||
|
||||
Exception &operator=(const Exception &inst);
|
||||
virtual const char* what(void) const throw();
|
||||
void ReportException (void) const;
|
||||
virtual void ReportException (void) const;
|
||||
inline void setMessage(const char * sMessage);
|
||||
inline void setMessage(const std::string& sMessage);
|
||||
|
||||
|
||||
@@ -71,9 +71,18 @@ PyException::PyException(void)
|
||||
|
||||
|
||||
_stackTrace = PP_last_error_trace; /* exception traceback text */
|
||||
}
|
||||
|
||||
PyException::~PyException() throw()
|
||||
{
|
||||
PyGILStateLocker locker;
|
||||
PyErr_Clear(); // must be called to keep Python interpreter in a valid state (Werner)
|
||||
}
|
||||
|
||||
void PyException::ReportException (void) const
|
||||
{
|
||||
Base::Console().Error("%s%s: %s\n",
|
||||
_stackTrace.c_str(), _errorType.c_str(), what());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
@@ -54,11 +54,12 @@ class BaseExport PyException : public Exception
|
||||
public:
|
||||
/// constructor does the whole job
|
||||
PyException(void);
|
||||
~PyException() throw() {}
|
||||
~PyException() throw();
|
||||
|
||||
/// this function returns the stack trace
|
||||
const std::string &getStackTrace(void) const {return _stackTrace;}
|
||||
const std::string &getErrorType(void) const {return _errorType;}
|
||||
void ReportException (void) const;
|
||||
|
||||
protected:
|
||||
std::string _stackTrace;
|
||||
|
||||
Reference in New Issue
Block a user