In DHTML we have a 'last ditch' error handler that handles any errors that bubble up to the window object, but that handler simply passes the error string to $reportSourceWarning, so the accompanying backtrace is meaningless. This is not a problem for wizards who can use Opera or Firebug to decrypt a backtrace from the compressed DHTML, but we could do better for the naive user by capturing our backtrace stack when an error is signaled and then using that captured stack for the default handler reports.
Test case:
<canvas>
<script>
function Foo () { null.bar(); };
(function test () {
Debug.info("Current line number");
new Foo();
})();
</script>
</canvas>
In Firefox this will currently report:
ERROR @
http://dueling-banjos.local:8080/ringding-clean/test/lpp-xxxx.lzx?lzt=object&lzt=object&debug=true&lzr=dhtml&lzbacktrace=true#50: null has no properties
but it really should report:
ERROR @lpp-xxxx.lzx#3: null has no properties
[I'm not sure I can make this work in any browser _other_ than Firefox -- they seem to abort our runtime as soon as an unhandled error is signalled.]
Changed paths:
M /openlaszlo/trunk/WEB-INF/lps/lfc/compiler/LzRuntime.lzs
M /openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzMessage.lzs
M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
Change 20071202-ptw-w by ptw@dueling-banjos.local on 2007-12-02 20:37:06 EST
in /Users/ptw/OpenLaszlo/ringding-2
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Debugger improvements to help me with diamond DHTML
Bugs Fixed:
LPP-5182'We could give better backtraces for unhandled errors in DHTML'LPP-5181'new calls do not have correct line number in backtrace'Technical Reviewer: dda@ddanderson.com (Message-Id: <FA6270BB-CDAD-4533-B76B-25F0D9981C6C@ddanderson.com>)
QA Reviewer: ewinard@laszlosystems.com (pending)
Details:
LzMessage: Look for saved backtrace
LzRuntime: Pass uncaught error backtrace to LzMessage
JavascriptGenerator, CodeGenerator: Break out call-site
annotation, use in function calls and new calls
JavascriptGenerator: Put a catch block around all functions to
record a backtrace if an exception is thrown and not caught.
Tests:
smokecheck, test case from bugs