For error reporting, I would like to insert a try-catch wrapper around the code of every function I have.
So basically I want to replace
function foo(ar
I don't have enough reputation to comment on the accepted answer.
I added a return before the f.apply to pass up the return value as well.
return
f.apply
var tcWrapper = function(f) { return function() { try { return f.apply(this, arguments); } catch(e) { customErrorHandler(e) } } }