Throw Python exceptions as Javascript exceptions

This commit is contained in:
Michael Droettboom 2018-02-26 16:11:36 -05:00
parent df1c2e2cad
commit bec7ce3e21
1 changed files with 6 additions and 6 deletions

View File

@ -10,20 +10,20 @@ val pythonExcToJs() {
PyObject *type;
PyObject *value;
PyObject *traceback;
PyObject *str;
PyObject *pystr;
PyErr_Fetch(&type, &value, &traceback);
str = PyObject_Str(value);
// TODO: Return a JS Error object rather than a string here...?
val result = pythonToJs(str);
pystr = PyObject_Str(value);
val Error = val::global("Error");
val exc = Error.new_(pythonToJs(pystr));
Py_DECREF(str);
Py_DECREF(pystr);
Py_DECREF(type);
Py_DECREF(value);
Py_DECREF(traceback);
return result;
return exc;
}
val pythonToJs(PyObject *x) {