watch this The wheels are turning, slowly turning. home
JavaScript source lines in Python tracebacks 2006-03-06


Added support to Athena today for generating tracebacks like this one:

2006/03/06 19:44 EST [HTTPChannel,250,127.0.0.1] Traceback (most recent call last):
          File "", line 0, in

        ---  ---
          File "", line 0, in

          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/runtime.js", line 39, in ()
            d.callback(result);
          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/divmod.js", line 136, in ([object Object])
            return methodFunction.apply(this, args);
          File "", line 0, in apply([object Object],[object Array])

          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/defer.js", line 137, in callback([object Object],[object Object])
            self._startRunCallbacks(result);
          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/divmod.js", line 136, in ([object Object])
            return methodFunction.apply(this, args);
          File "", line 0, in apply([object Object],[object Array])

          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/defer.js", line 134, in _startRunCallbacks([object Object],[object Object])
            self._runCallbacks();
          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/divmod.js", line 136, in ()
            return methodFunction.apply(this, args);
          File "", line 0, in apply([object Object],[object Array])

          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/defer.js", line 108, in _runCallbacks([object Object])
            self._result = callback.apply(null, args);
          File "", line 0, in apply(null,[object Array])

          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/athena.js", line 259, in ([object Object])
            action.apply(null, actionArgs);
          File "", line 0, in apply(null,[object Array])

          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/athena.js", line 191, in ("Nevow.Athena.callByAthenaID","s2c241",[object Array])
            result = funcObj.apply(null, funcArgs);
          File "", line 0, in apply(null,[object Array])

          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/athena.js", line 609, in (14,"setStatus",[object Array])
            var widget = Nevow.Athena.Widget.fromAthenaID(athenaID);
          File "/home/exarkun/Projects/Divmod/trunk/Nevow/nevow/athena.js", line 601, in (14)
            throw new Error(nodes.length + " nodes with athena id " + widgetId);
          File "", line 0, in Error("0 nodes with athena id 14")

        nevow.athena.JSException: Error: 0 nodes with athena id 14





Still a bit unsightly: function arguments probably shouldn’t show up, anonymous functions should be reported as ”” instead of “”, every other frame should be omitted (or Athena shouldn’t insert those in the first place, ah but it really needs to). It’d also be nice to have the first stanza filled out (the bit before — —), as it is with real Python exceptions.




Anyway, the coolest part is how emacs can parse these and automatically open the appropriate JavaScript file for me when an unhandled error occurs in the browser during debugging.