Poor man's JavaScript debugger
// Hold the trace data
var trace = String();
// Debug log method
function debug(str)
{
if(trace.length > 0) trace += "\n-> ";
trace += str;
}
// The function with errors
function advancedFunction()
{
try
{
debug("advancedFunction()");
debug("doing this");
doThis();
debug("doing that");
doThat();
debug("doing other");
doOther();
}
catch(ex)
{
debug(ex.message);
alert(trace);
}
}
Comments