Redirecting all function calls in JS -- Possible?
Posted: Tue Dec 13, 2005 12:01 pm
Hi,
I'm working on a JavaScript Exception Handling object which allows developers to log *useful* debug errors in a database via AJAX or such like (or use a user defined callback function to do as they please).
It currently works just fine if you specifically call the error handler at runtime but what I'm wondering is....
"Is there any way I can automatically capture all function calls and manipulate them to use the exception handler?"
It's a bit of a longshot and probably impossible due to security implications but it would make my whole script a lot nicer if users could do something like
Possible?

I'm working on a JavaScript Exception Handling object which allows developers to log *useful* debug errors in a database via AJAX or such like (or use a user defined callback function to do as they please).
It currently works just fine if you specifically call the error handler at runtime but what I'm wondering is....
"Is there any way I can automatically capture all function calls and manipulate them to use the exception handler?"
It's a bit of a longshot and probably impossible due to security implications but it would make my whole script a lot nicer if users could do something like
Code: Select all
var exceptionHandler = new ExceptionHandler();
exceptionHandler.setCallback(foo);
exceptionHandler.autoCapture(); //Capture EVERYTHING automatically
function foo(e)
{
alert(e);
}
function somethingBad()
{
wonky[2] = 42; //wonky is undefined so this should get handled gracefully by the exception handler
return wonky[2];
}
var b0rken = somethingBad();