Hal's example of nested acception handling is pretty cool. If that's
what you want to do, it's a great idea.
Another great idea, which I myself use all the time, came from Steve
about a year ago. Just put the following in your application.cfm,
or MyGlobals.cfm for XFB:
<cfparam name="attributes.debug" default="0">
<CFIF attributes.debug NEQ "1">
<CFERROR TYPE="EXCEPTION" EXCEPTION="any" TEMPLATE="act_error.cfm">
</CFIF>
Actually, for XFB, if you put it inside the
<cfif NOT IsDefined( 'request.Circuits' )></cfif>
then only the main application will catch the error, and you only need
to have one act_error.cfm. If you want circuit level error catching,
Hal's method is the way to go. I don't really care, because I just
want to catch the error and be notified. So global error catching
works for me.
You could make a fuse for an error, but I don't think it matters
all that much.
Your act_error could do something like:
<pseudocode>
OOPS! An error has occured...
The system administrator has been notified.
<a href="javascript:back();">back</a>
</pseudocode>
<CFTRY>
<CFMAIL to you, from you, type="HTML" etc>
<table border="1">
<tr>
<td>
<b>Error Diagnostic Information</b>
<p>
<cfif
isdefined("error.EXTENDEDINFO")>EXTENDEDINFO=#error.EXTENDEDINFO#<cfelse>no
EXTENDEDINFO</cfif><BR>
<cfif
isdefined("Error.Diagnostics")>Diagnostics=#Error.Diagnostics#<cfelse>no
Diagnostics</cfif>
<p>
<cfif
isdefined("Error.Template")>Template=#Error.Template#<cfelse>no
Template</cfif><BR>
<cfif
isdefined("CFCATCH.EXTENDEDINFO")>EXTENDEDINFO=#CFCATCH.EXTENDEDINFO#<cfelse
>no EXTENDEDINFO</cfif><BR>
<cfif
isdefined("CFCATCH.Message")>#CFCATCH.Message#<cfelse>No
message</cfif>
<p>
<cfif
isdefined("cfcatch.type")>#cfcatch.type#<cfelse>No type</cfif><BR>
<cfif
isdefined("cfcatch.detail")>#cfcatch.detail#<cfelse>No
detail</cfif><BR>
<cfif
isdefined("CFCATCH.ErrNumber")>#CFCATCH.ErrNumber#<cfelse>No
ErrNumber</cfif><BR>
<cfif
isdefined("CFCATCH.LockName")>#CFCATCH.LockName#<cfelse>No
LockName</cfif><BR>
<cfif
isdefined("CFCATCH.LockOperation")>#CFCATCH.LockOperation#<cfelse>No
LockOperation</cfif><BR>
<cfif
isdefined("CFCATCH.MissingFileName")>#CFCATCH.MissingFileName#<cfelse>No
MissingFileName</cfif><BR>
<cfif
isdefined("CFCATCH.NativeErrorCode")>#CFCATCH.NativeErrorCode#<cfelse>No
NativeErrorCode</cfif><BR>
<cfif
isdefined("CFCATCH.SQLState")>#CFCATCH.SQLState#<cfelse>No
SQLState</cfif><BR>
<cfif isdefined("form.fieldnames")>
#form.fieldnames#<br>
<cfloop list="#form.fieldnames#" index="field">
#field# =
#evaluate("form.#field#")#<br>
</cfloop>
</cfif>
<br>
<cfif
isdefined("request.urltoken")>#request.urltoken#</cfif><br>
<cfif isdefined("cgi.path_info")>
PATH_INFO = #cgi.path_info#<br>
</cfif>
<cfif isdefined("cgi.query_string")>
query_string = #cgi.query_string#<br>
</cfif>
<cfif isdefined("cgi.HTTP_USER_AGENT")>
HTTP_USER_AGENT = #cgi.HTTP_USER_AGENT#<br>
</cfif>
<cfif isdefined("cgi.REMOTE_ADDR")>
REMOTE_ADDR = #cgi.REMOTE_ADDR#<br>
</cfif>
<cfif isdefined("cgi.HTTP_REFERER")>
HTTP_REFERER = #cgi.HTTP_REFERER#<br>
</cfif>
<cfif isdefined("cgi.CF_TEMPLATE_PATH")>
TEMPLATE = #cgi.CF_TEMPLATE_PATH#<br>
</cfif>
#dateformat(now(),"mm/dd/yyyy")#
#timeformat(now(),"hh:mm tt")#<br>
<cfif
isdefined("Error.GeneratedContent")>GeneratedContent=#Error.GeneratedContent
#<cfelse>No generated content</cfif>
</td>
</tr>
</table>
</CFTRY>
> -----Original Message-----
> From: Gary Morin [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 16, 2001 10:06 AM
> To: Fusebox
> Subject: Error Handling
>
>
> Hi All
>
> I'm just about to start implementing error handling in XFB
> application, I
> will probably implement code similar to Hal Helms nested
> error handling
> code.
>
> Often errors are generated/captured in act_ pages, from the
> user perspective
> a polite message informing him of the error and requesting to do the
> appropriate action to correct the problem, this action may be
> refreshing the
> page, or doing a login etc. Cftry and Cfcatch will be used to
> handle the
> errors
>
> My question is what is the excepted way to notify the problem
> to the user?
> In some examples, including Hal's, HTML messages are placed
> directly in the
> act file or even in the index.cfm, if the nested error
> handling code is
> used. Or should I use an 'Error fuse' to display and error
> message and use
> a XFA to return the user to the appropriate position to
> continue( this would
> also require all variables to be passed through the error
> handling code).
>
> So how do others handle simple errors and informing users?
>
> Cheers
>
> Gary
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists