Skip to content

Commit

Permalink
Adds better stack trace to error messages
Browse files Browse the repository at this point in the history
Found that in Chrome when an error happens in say a handler function the
try/catch block would catch the error and pass it along to the debug()
method. The problem is that when the debug function in turn does a
console.log(err) it looses the stack trace and your not able to see what
happened.

This might be the limitations of Chrome's console but adding the
err.stack allows the developer a peek into the cause of any errors
thrown.
  • Loading branch information
sukima committed Dec 13, 2012
1 parent d29c35d commit 1164588
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion js/jquery.mobile.router.js
Expand Up @@ -38,7 +38,10 @@ $(document).bind("mobileinit",function(){

var DEBUG=true;
function debug(err){
if (DEBUG) console.log(err);
if (DEBUG) {
console.log(err);
if (err.stack) console.log(err.stack)
}
}

var previousUrl=null, nextUrl=null, ignoreNext=false;
Expand Down

0 comments on commit 1164588

Please sign in to comment.