Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFTRY/CATCH question(s) 1

Status
Not open for further replies.

OldWilly

Programmer
Mar 1, 2002
66
Is there a way of using CFTRY/CATCH on full pages to see if a customer is experiencing difficulties? -- then emailing the error to myself? We suspect there might be errors
(ones we can't duplicate) and would like to know what they are. If there is any such thing (especially getting the err msg to me), I would love to see some code examples.
 
this is what i use

<cftry>

code you want to check

<cfcatch type=&quot;ANY&quot;>
<!--- custom tag --->
<cf_email_errors type=&quot;#cfcatch.Type#&quot; message=&quot;#cfcatch.Message#&quot; detail=&quot;#cfcatch.Detail#&quot; TagContext=&quot;#cfcatch.TagContext#&quot; Subject=&quot;eCAPRIS - Website Error&quot;>
<!--- custom error page that you want to display --->
<cflocation url=&quot;index.cfm?main=home&sub=error&quot; addtoken=&quot;no&quot;>
</cfcatch>
</cftry>

<!--- custome tag******************************************************** --->
<!--- Set Variable Defaults --->

<cfparam name=&quot;attributes.subject&quot; default=&quot;NA&quot;>
<cfparam name=&quot;attributes.type&quot; default=&quot;NA&quot;>
<cfparam name=&quot;attributes.message&quot; default=&quot;NA&quot;>
<cfparam name=&quot;attributes.detail&quot; default=&quot;NA&quot;>
<cfparam name=&quot;attributes.TagContext&quot; default=&quot;NA&quot;>

<cfset theError = attributes.tagContext[ArrayLen(attributes.tagContext)]>
<cfset variables.getPages = &quot;&quot;>
<cfset variables.pageList = &quot;&quot;>
<cfloop from=&quot;1&quot; to=&quot;#ArrayLen(attributes.tagContext)#&quot; index=&quot;i&quot;>
<cfset sCurrent = attributes.tagContext />
<cfif NOT listFind(variables.getPages,sCurrent[&quot;TEMPLATE&quot;],&quot;,&quot;)>
<cfset variables.getPages = listAppend(variables.getPages, sCurrent[&quot;TEMPLATE&quot;],&quot;,&quot;)>
</cfif>
</cfloop>
<cfset variables.pageList = listChangeDelims(variables.getPages,&quot;<br>&quot;, &quot;,&quot;)>

<!--- Send Email Alert With Debug Info --->
<cfmail to=&quot;#request.adminEmail#&quot; from=&quot;#request.adminEmail#&quot; subject=&quot;#attributes.subject#&quot; type=&quot;HTML&quot;>
<strong>username:</strong> - #session.USER_NAME#<br>
<strong>employee id:</strong> - #session.EMPLOYEE_ID#<br>
<strong>email_addr:</strong> - #session.email_addr#<br>
<hr>
<strong>Error Type:</strong> - #attributes.Type#<br>
<strong>Error Message:</strong> - #attributes.Message#
<strong>Error Details:</strong><br>
#attributes.Detail# <br>
<hr>
The error occurred while processing an element with a general identifier of (#theError[&quot;ID&quot;]#), occupying document position (#theError[&quot;LINE&quot;]#:#theError[&quot;COLUMN&quot;]#) in the template file #theError[&quot;TEMPLATE&quot;]#.
<hr>
<br>
<strong><u>All Templates Called For this Display:</u></strong>
<br>
<br>
#variables.pageList#
</cfmail>
<!--- --->
<!--- ******************************************************************* --->


------------------------------------------------------------------------------
brannonH
if( !succeed ) try( );
 
thank you so much. I appreciate the code example.
Bill
wpontius@sc.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top