The Robertson Team


 

 
 
 
 
 
  Programmers' Tools >  The Free Stuff >  Free ColdFusion Tutorials >  How Do I Do An Error Handler? >  Listing 3
 

Listing 3

<cfparam name="request.dumpMode" default="" type="string">
<cfparam name="request.emailTo" default="" type="string">
<cfparam name="request.emailFrom" default="" type="string">
<cfparam name="request.emailServer" default="" type="string">
<cflock scope="SERVER" type="READONLY" timeout="10">
 <cfset variables.CFVer=Left(server.coldfusion.ProductVersion,1)>
</cflock>
<cfscript>
request.vars="CFCATCH,ERROR,APPLICATION,ATTRIBUTES,CALLER,CGI,
              CLIENT,FORM,REQUEST,SESSION,THIS,THISTAG,URL,VARIABLES";
request.theFileName=Replace(CreateUUID(),"-","","all");
request.errorDirectory="c:/cfusionmx/wwwroot/myerrors/";
request.errorDomain="
https://www.mydomain.com/errors/";
variables.Security="&lt;variables.PageStatus=""1""&gt;" & chr(10);
variables.Security=variables.Security & "&lt;cfinclude template=""inc_logincheck.cfm""&gt;" & chr(10);

</cfscript>
<cffile 
   action="write" 
   file="#request.errorDirectory##request.theFileName#.cfm" 
   output="#variables.Security#" 
   addnewline="Yes">

<cfsavecontent variable="variables.dataDump">
<cfloop
  list="#request.vars#"
   index="loopItem">
   <cfif IsDefined("#loopItem#")>
      <cfif Compare(variables.CFVer,6)>
         <br><br><cfoutput><b>#loopItem#</b></cfoutput>
      </cfif>
      <cfdump
         var="#Evaluate(loopItem)#"
         label="#loopItem#">
   </cfif> 
</cfloop>
</cfsavecontent>
<cffile
   action="write"
   file="#request.errorDirectory##request.theFileName#.cfm"
   output="#variables.dataDump#"
   addnewline="Yes"
>
<cfswitch expression="#request.dumpMode#">
   <cfcase value="STANDARD">
      <cfmail
         to="#request.emailTo#"
         from="#request.emailFrom#"
         subject="#cgi.server_name# Error"
         server="#request.emailServer#"
         type="HTML"
         mimeattach="#request.errorDirectory##request.theFileName#.cfm">
         <p>
         <a href="#request.errorDomain#list.cfm"
>
        
See complete error list
        
</a>
         </p>
      </cfmail>
   </cfcase>
   <cfcase value="SECURE">
      <cfmail
         to="#request.emailTo#"
         from="#request.emailFrom#"
         subject="#cgi.server_name# Error"
         server="#request.emailServer#"
         type="HTML">
         <p>
         <a href="#request.errorDomain##request.theFileName#.cfm"
>
        
See It
        
</a>
         </p>
         <p>
         <a href="#request.errorDomain#list.cfm"
>
         
See complete error list
        
</a>
         </p>
      </cfmail>
   </cfcase>
   <cfcase value="ONSCREEN">
      <cfoutput>
      #variables.dataDump#
      </cfoutput>
   </cfcase>
</cfswitch>


The Robertson Team, TheKing@mysecretbase.com
1.559.360.1717 


HostMySite.com is a leader in ColdFusion web hosting and managed dedicated servers.