wojtossfm / pyv8

Automatically exported from code.google.com/p/pyv8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No way to get stack trace from javascript TypeError or ReferenceError

GoogleCodeExporter opened this issue · comments

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

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

  • Changed state: Accepted
  • Added labels: OpSys-All