Code
/*
wwJsError (requires prototype.js)
send: sends javascript error output email via coldfusion
--------------------
path: relative path from the calling page to the coldfusion
email handler for this application (usually processJSerror.cfm)
funcname: name of the JavaScript function that threw an error
name: JavaScript error name (usually e.name in a catch block)
message: JavaScript error message (usually e.message in a catch block)
*/
var wwJsError = {
send: function(path,funcname,name,message) {
try {
var url = path;
var pars = 'message=' + escape(message) + '&name=' +
escape(name) + '&funcname=' + escape(funcname);
var httpMail = new Ajax.Request (
url,
{
method: 'post',
parameters: pars,
onComplete: Prototype.emptyFunction
}
);
} catch (e) {
//if sending the email fails, just die quietly w/ no browser error
Prototype.emptyFunction();
}
}
}; //end wwJsError
<cfmail to="#application.administratoremail#" from="#application.administratoremail#"
subject="#application.apptitle# Error" type="HTML">
<strong>JavaScript Error:</strong> #form.funcname# threw the following error:<br />
<br />
<strong>Error name:</strong> #form.name#<br />
<strong>Error:</strong> #form.message#
</cfmail>
function makeError() {
try {
alert(anError);
} catch(e) {
wwJsError.send('cf/processJSerror.cfm','makeError()',e.name,e.message);
}
}
