Burrito wrote:have you looked into a try / catch scenario?
That's what's going on inside the exceptionHandler object yes.
I'll try to explain better.
To save repeating the whole try/catch scenario over and over for the developer point of view I'm writing an object (code will be revealed when happy it's ready for public use) to handle it automatically. It's not simply a try/catch system... it does have other features to such as capturing information about the client and where the error occurred etc that's why I'm writing it.
Currently it accepts a user-written callback function to process the debug output and not display anything to the client. It's using eval() to run any code given to it (I'll try and change that if I can although it seems to work just fine). A user defined callback function might be something like an AJAX request to log the error in a database on the client side but for simpicity here we'll just alert() the error directly to the browser window.
Presently you'd do something like this:
Code: Select all
<script type="text/javascript" src="exceptionHandler.js"></script>
<script type="text/javascript">
<!--
var exceptionHandler = new ExceptionHandler(); //Construct our object
exceptionHandler.setCallback(handleMyErrors); //Tell it what to use as a callback function
function handleMyErrors(errorMsg)
{
alert(errorMsg);
}
function thisIsBroken()
{
dog[10] = 42; //No such defined variable so bail out usually but we'll handle it here
}
// -->
</script>
<body>
<a href="javascript:exceptionHandler.run('thisIsBroken()');">Click here to fail gracefully</a>
</body>
Now as you can see it might become a little tedious for the developer to have to pass all code he/she wants to exeute through the exception handler
In the same way that you can captureEvents() and handle them gracefully I'm hoping that I can automatically pass any executed ajavscript through the exception handler too (sounds crazy now I read it back

).
If I can't do that then what would be second best is to capture ALL possible events -- easy.... then find out what the event call was intended for. So in the above case I'd need to know that the event was a click and that the user was running the thisIsBroken() function with no arguments.... I'd have no clue how to go about that
Thanks for reading all my gibberish
