Mercurial > pymonkey
diff utils.c @ 47:3f4982759e55
Converting JS exceptions into Python exceptions is now doable, albeit not yet implemented, thanks to the discovery of JSOPTION_DONT_REPORT_UNCAUGHT. Also, JS warnings are now converted into Python warnings.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Mon, 06 Jul 2009 08:13:45 -0700 |
parents | a0f677cfc679 |
children | bc4263c6ae82 |
line wrap: on
line diff
--- a/utils.c Mon Jul 06 01:37:16 2009 -0700 +++ b/utils.c Mon Jul 06 08:13:45 2009 -0700 @@ -146,10 +146,11 @@ JS_ReportError(context->cx, "Python exception occurred"); else { jsval val; - if (PYM_pyObjectToJsval(context, str, &val) == 0) - // TODO: Include filename/line information. + if (PYM_pyObjectToJsval(context, str, &val) == 0) { + // TODO: Wrap Python traceback info in JS exception so the client + // can examine it. JS_SetPendingException(context->cx, val); - else + } else JS_ReportError(context->cx, "Python exception occurred"); } @@ -169,6 +170,8 @@ if (JS_GetPendingException(context->cx, &val)) { JSString *str = JS_ValueToString(context->cx, val); if (str != NULL) { + // TODO: Wrap the original JS exception so that the client can + // examine it. const char *chars = JS_GetStringBytes(str); PyErr_SetString(PYM_error, chars); } else