I used https://github.com/eriwen/javascript-stacktrace to capture stack trace when exception happens.
In some cases the logged information looks very strange, for example the user uses IE9 and the logged message is at {anonymous}()
 at printStackTrace()
 at {anonymous}(#object,"error","")
 at {anonymous}(#object,[#object...""])
 at d(12031,"",#object,"")
 at {anonymous}()
.
In my code I have quite some jQuery event handling code
$(document).ready(function () {
$('#reset').bind('click', reset);
}
function reset(e){
$.ajax({
type: 'POST',
url: '/my/url',
dataType: "json",
success: function (result) {
// do something useful
},
error: function (request, error) {
// log to server side.
logError(error, printStackTrace());
}
});
}
I think in this case the captured stack trace just look like anonymous objects.
Is there a better way I can capture stack trace in a more readable way?
I think I know the reason, according to http://kangax.github.com/nfe/ function expressions is the only way to get a truly robust stack inspection
.
So in the coding, we have to consider how to create function in order to allow debugger to capture the name.