Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed minor error

  • Loading branch information...
commit 2c0697c3caf63187c95ebb3e782ef24978dfffed 1 parent eb077da
Richard Laughlin rcythr authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 src/swganh/scripting/utilities.cc
28 src/swganh/scripting/utilities.cc
View
@@ -0,0 +1,28 @@
+#include "utilities.h"
+
+#include "swganh/logger.h"
+#include <boost/python.hpp>
+
+using namespace swganh::scripting;
+
+void swganh::scripting::logPythonException()
+{
+ PyObject *exc, *val, *tb;
+ PyErr_Fetch(&exc, &val, &tb);
+ PyErr_NormalizeException(&exc, &val, &tb);
+ boost::python::handle<> hexc(exc), hval(boost::python::allow_null(val)), htb(boost::python::allow_null(tb));
+ if(!hval)
+ {
+ LOG(error) << std::string(boost::python::extract<std::string>(boost::python::str(hexc)));
+ }
+ else
+ {
+ boost::python::object traceback(boost::python::import("traceback"));
+ boost::python::object format_exception(traceback.attr("format_exception"));
+ boost::python::list formatted_list(format_exception(hexc,hval,htb));
+ for(int count = 0; count < len(formatted_list); ++count)
+ {
+ LOG(error) << std::string(boost::python::extract<std::string>(formatted_list[count].slice(0,-1)));
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.