Hola Martin,
That's a very good question (which means I don't really have a good answer
;-)
I was using (b) but with a relocation back to the page to discard partial
output, but this is not ideal.
I discarded (a) because you get stuck with partial output up to the point of
the exception - and if you try using CFCONTENT with reset you get a fun CF
error message about trying to modify discarded output.
So came up with the following (c) a modification of the (b) form, also to
fire proof it I wrap all of app_locals with a try catch which in case of
error changes the fuseaction to "Error" which is then handled as a regular
fuseaction.
Please let me know if there are any holes in it.
Saludos,
Noam
(c)
<cfinclude template="app_locals.cfm">
<cftry>
<cf_bodycontent>
...
<cfcase value="Error">
<CFINCLUDE template="act/act_Error.cfm">
<cfinclude template="dsp/dsp_Error.cfm">
</cfcase>
...
</cf_bodycontent>
<CFCATCH TYPE="Any">
<!--- Clear out partial output before exception --->
<cfcontent type="text/html" Reset="Yes">
<!--- Display friendly error message with some debug info instead of
ugly CF crash --->
<CFINCLUDE template="act/act_Error.cfm">
<cf_bodycontent>
<cfinclude template="dsp/dsp_Error.cfm">
</cf_bodycontent>
</CFCATCH>
</CFTRY>
<cfinclude template="app_layout.cfm">
----------
From: Martin Cadirola [SMTP:[EMAIL PROTECTED]]
Sent: Thursday, 23 November 2000 5:46
To: Fusebox
Subject: cftry/cfcatch positioning wrt cf_bodycontent
Hello Folks,
I'm almost done with the Fusebox book (excellent job!) and working
on a
few projects with CF. I've used CFTRY/CFCATCH before but I'm not
sure
where to put them when using CF_BODYCONTENT. Should it be (a) or
(b)?
(please see below)
Thanks in advance and Happy Thanksgiving!
Cheers,
Mart�n Cadirola
-----------------------------------------------------------------------
(a) A "home application" index.cfm:
<cfinclude template="app_globals.cfm">
<cf_bodycontent>
<cftry>
<cfparam name="attributes.fuseaction" default="">
<cfswitch expression="#attributes.fuseaction#">
<cfcase value="blah">
this
</cfcase>
<cfcase value="blahblah">
that
</cfcase>
</cfswitch>
<cfcatch type="Any">
<cfinclude
template="actions/act_InformProblems.cfm">
<cfinclude template="displays/dsp_Error.cfm">
</cfcatch>
</cftry>
</cf_bodycontent>
<cfinclude template="app_layout.cfm">
(b)
<cfinclude template="app_globals.cfm">
<cftry>
<cf_bodycontent>
<cfparam name="attributes.fuseaction" default="">
<cfswitch expression="#attributes.fuseaction#">
<cfcase value="blah">
this
</cfcase>
<cfcase value="blahblah">
that
</cfcase>
</cfswitch>
</cf_bodycontent>
<cfinclude template="app_layout.cfm">
<cfcatch type="Any">
<cfinclude template="actions/act_InformProblems.cfm">
<cfinclude template="displays/dsp_Error.cfm">
</cfcatch>
</cftry>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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?sidebarRsts