Exception Handling Problem
I'm trying to write a separate error handler to handle all errors in CFScript.
But, I'm running into two issues:
1. rethrow excp
produces "Invalid CFML construct".
In Developing ColdFusion 9 Applications, Ch. 4, pg. 108,
New tag equivalents in CFScript,
<cfrethrow>'s CFScript equivalent is "rethrow".
Do you know if the docmentation is incorrect?
Did they not get "rethrow" into CF9?
2. What data type are exceptions?
I'm trying to pass an exception to my error handler as
an Object, but I get the error:
"The EXCP argument passed to the errorHandler function is not of type Object."
However, IsObject(excp)=true in my calling function.
Below is an example of what I'm trying to do.
Thanks,
myscreenname0345
=============================================================
<cfscript>
//-----------------------------------------------------------
public void function myFunc() {
try {
var i = 1/0; // Divide by 0 will generate exception.
} catch (any excp) {
rethrow excp;
}
}
//-----------------------------------------------------------
public void function errorHandler(Object excp) {
variables.scriptFailed = true;
writelog(file="logfile", text="#excp.Message#");
}
//----------------- Main ------------------------------------
scriptFailed = false;
try {
myFunc();
} catch (any excp) {
writeOutput(IsObject(excp));
errorHandler(excp);
} finally {
writelog(file="logfile", text="#variables.scriptFailed#");
}
</cfscript>
=============================================================
