diff --git a/triqs/python_tools/wrapper_tools.hpp b/triqs/python_tools/wrapper_tools.hpp index f504420d..aafd71ef 100644 --- a/triqs/python_tools/wrapper_tools.hpp +++ b/triqs/python_tools/wrapper_tools.hpp @@ -6,21 +6,28 @@ #include #include #include "./pyref.hpp" +#include #pragma clang diagnostic ignored "-Wdeprecated-writable-strings" #pragma GCC diagnostic ignored "-Wwrite-strings" +inline char *get_current_time() { // helper function to print the time in the CATCH_AND_RETURN macro + time_t rawtime; + time(&rawtime); + return ctime(&rawtime); +} + // I can use the trace in triqs::exception #define CATCH_AND_RETURN(MESS,RET)\ catch(triqs::keyboard_interrupt const & e) {\ PyErr_SetString(PyExc_KeyboardInterrupt, e.what());\ return RET; }\ catch(triqs::exception const & e) {\ - auto err = std::string("Error " MESS "\nC++ error was : \n") + e.what();\ + auto err = std::string("Error occurred at ") + get_current_time() + "\nError " + MESS + "\nC++ error was : \n" + e.what();\ PyErr_SetString(PyExc_RuntimeError, err.c_str());\ return RET; }\ catch(std::exception const & e) {\ - auto err = std::string("Error " MESS "\nC++ error was : \n") + e.what();\ + auto err = std::string("Error occurred at ") + get_current_time() + "\nError " + MESS + "\nC++ error was : \n" + e.what();\ PyErr_SetString(PyExc_RuntimeError, err.c_str());\ return RET; }\ catch(...) { PyErr_SetString(PyExc_RuntimeError,"Unknown error " MESS ); return RET; }\ diff --git a/triqs/utility/exceptions.hpp b/triqs/utility/exceptions.hpp index c117943c..4c5f979a 100644 --- a/triqs/utility/exceptions.hpp +++ b/triqs/utility/exceptions.hpp @@ -31,13 +31,14 @@ namespace triqs { class exception : public std::exception { - std::string acc, trace; + std::string acc, _trace; public: - exception() throw() :std::exception() { trace = utility::stack_trace();} + exception() throw() :std::exception() { _trace = utility::stack_trace();} virtual ~exception() throw() {} template exception & operator <<( T const & x) { std::stringstream f; f<