First, the JavaScript code. Near the top of my main JavaScript file that I include on every page of my application, I put this code that I found online and modified for my own use. I should note here that I am using jQuery (and you should to).
window.onerror = function(m,u,l){ $.post( basePath + "/js_error.cfm", { msg: m, url: u, line: l, window: window.location.href } ); return true; }All this code is doing is catching untrapped errors and posting them to a page on the server. Now for the server-side code:
The ColdFusion script write the error to a log file and then emails me the report.#errorReport#
For now this will blindly send me error reports in the background. But in the future I would like to pop up a form to the user to get more information such as asking what they were trying to do when they got the error. I built a prototype using the jQuery UI dialog module. However, I need to work out some more UX questions like:
- How often do I ask for input especially if it's an error they are getting on every page?
- Should I pilot this dialog to select users first?
- Would a live chat with tech support be an option (using web sockets)?