Better runtime errors
I use js2py to integrate existing JS code (6200 lines) into a Python project, by injecting Python objects into the Javascript context, that emulate functions that were previously provided by ActiveX Objects.
The mechanism basically works, but debugging is difficult:
All runtime errors (whether in JS or in Python called from JS) have a pretty useless stacktrace. They mostly show a position in evaljs.py and have no information about the JS context (like linenumbers (in the original JS) or a JS stacktrace.
Is there a way of getting that context (at least for debugging)?
Thanks, this is a good point, error messages are not very user-friendly as they point to the auto-generated and not very readable python code. They should point to the relevant JS source code lines instead.
One idea to do that without a huge slow-down would be to create the source map and include it as a static data at the top of the script. The map would allow to find the corresponding source JS line from each line of the generated python code. In case error is raised the map would be used to make the exception more readable (ie translate the python exception back to the JS exception).
I will not have the time to do that now, but pull requests are welcome :)