This is what I got from today's lesson ...
Application.cfc - OnError:
<cffunction name="onError" access="public">
<cfargument name="exception" required="true">
<cfargument name="EventName" type="String" required="true">
<!---if the request is ajax, throw an error that can be returned
to the client in a basic string and then log the error as usual--->
<cfif StructKeyExists(requestHeaders, "X-Requested-With") and
StructFind(requestHeaders,"X-Requested-With") eq "XMLHttpRequest">
<cfthrow errorcode="500" message="ColdFusion Error">
<cfelse>
<cfdump var="#arguments.exception#">
</cfif>
</cffunction>
Client side script:
$.ajaxSetup({
error:function(x,e){
if(x.status == 500 && x.statusText == "SessionTimeout") {
alert("Your session has timed out.");
location.href = 'login.cfm';
}
else if(x.status == 500 && x.statusText == "ColdFusion Error"){
alert(x.statusText);//test for coldfusion error
}
}
});
Thanks Ray. This is what I needed today.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336910
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm