comparison utils.c @ 74:e06376295170

JS exceptions thrown out to Python now include the wrapped original exception. This fixes a TODO.
author Atul Varma <varmaa@toolness.com>
date Wed, 29 Jul 2009 20:43:46 -0700
parents c2972e58fbb6
children 4b1149d818e8
comparison
equal deleted inserted replaced
73:efa0cfe6fc03 74:e06376295170
203 PyErr_Occurred()) 203 PyErr_Occurred())
204 return; 204 return;
205 205
206 jsval val; 206 jsval val;
207 if (JS_GetPendingException(context->cx, &val)) { 207 if (JS_GetPendingException(context->cx, &val)) {
208 JSString *str = NULL; 208 PyObject *obj = PYM_jsvalToPyObject(context, val);
209 209 if (obj) {
210 Py_BEGIN_ALLOW_THREADS; 210 PyErr_SetObject(PYM_error, obj);
211 str = JS_ValueToString(context->cx, val); 211 Py_DECREF(obj);
212 Py_END_ALLOW_THREADS; 212 } else {
213 213 PyErr_Clear();
214 if (str != NULL) { 214
215 // TODO: Wrap the original JS exception so that the client can 215 JSString *str = NULL;
216 // examine it. 216
217 const char *chars = JS_GetStringBytes(str); 217 Py_BEGIN_ALLOW_THREADS;
218 PyErr_SetString(PYM_error, chars); 218 str = JS_ValueToString(context->cx, val);
219 } else 219 Py_END_ALLOW_THREADS;
220 PyErr_SetString(PYM_error, "JS exception occurred"); 220
221 if (str != NULL) {
222 const char *chars = JS_GetStringBytes(str);
223 PyErr_SetString(PYM_error, chars);
224 } else
225 PyErr_SetString(PYM_error, "JS exception occurred");
226 }
221 } else 227 } else
222 PyErr_SetString(PYM_error, "JS_GetPendingException() failed"); 228 PyErr_SetString(PYM_error, "JS_GetPendingException() failed");
223 } 229 }