code-google-com / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

No way to get stack trace from javascript TypeError or ReferenceError #178

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Run something like the following:

import PyV8
c = PyV8.JSContext()
c.enter()
c.eval("function f(){foo = null; foo.bar();};")
c.eval("f()")

The resulting exception shows the line of the error, but there appears to be no 
way to get the full stack trace (like there would be if the code was something 
like 'throw Error()')

Original issue reported on code.google.com by russell....@gmail.com on 4 Jun 2013 at 12:29

GoogleCodeExporter commented 9 years ago
It's a design issue, because the build-in Javascript error will be mapping to 
build-in Python exception

static struct {
  const char *name;
  PyObject *type;
} SupportErrors[] = {
  { "RangeError",     ::PyExc_IndexError },
  { "ReferenceError", ::PyExc_ReferenceError },
  { "SyntaxError",    ::PyExc_SyntaxError },
  { "TypeError",      ::PyExc_TypeError }
};

So, after translate the exception, the stack trace will be lost in the current 
implementation.

I will work on it later, maybe add it to Exception object

Original comment by flier...@gmail.com on 14 Jun 2013 at 6:43