No issues. And a catch type is not needed. When the
catch type is left out, then the default is "any".
I think the issue here is that there is a difference
between exceptions and errors. Errors occur at first
pass compilation before the code on the page is
actually run. Exceptions occur at run time. Try and
Catch blocks only catch exceptions. What is probably
happening is that the code is causing an error and not
an exception, therefore the try is not catching the
error. The cfswitch is not preventing the cfcatch
from catching the exceptions. So all I might have
done for you is to clarify what can be caught by try
blocks and what cannot as well as clarify that the
problem is not due to the cfswitch.
The following code proves that an exception thrown by
code inside a case statement can be caught.
<cfset myvar = 1>
<CFTRY>
<CFSWITCH EXPRESSION="#myvar#">
<CFCASE VALUE="1">
<!-- throws a missing include -->
<CFINCLUDE template="bla.cfm">
</CFCASE>
<CFCASE VALUE="2">
<!--- this causes an expression exception because it
accesses a variable that is not defined --->
<CFOUTPUT>#thisvar#</CFOUTPUT><BR>
</CFCASE>
<CFDEFAULTCASE>
default case <BR>
</CFDEFAULTCASE>
</CFSWITCH>
<CFCATCH>
<CFOUTPUT>
#cfcatch.type#<BR>
</CFOUTPUT>
</CFCATCH>
</CFTRY>
--- Mike Townend <[EMAIL PROTECTED]> wrote:
>
> You will need to put a catch type in... try
>
> <CFTRY>
>
> <CFSWITCH etc etc>
> (all the stuff)
> </CFSWITCH>
>
> <CFCATCH TYPE="Any">
> arrrrrhhhhhhhhhhh!!
> </CFCATCH>
> </CFTRY>
>
>
> -----Original Message-----
> From: Scott Weikert [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 18, 2001 18:00
> To: CF-Talk
> Subject: cftry/cfcatch and cfswitch issues?
>
>
> Hey gang,
>
> A fellow co-worker is working on adding some
> CFTRY/CFCATCH goodies to a site
> we're working on. It's a semi-FuseBox site - not
> 100% Fusebox but close
> enough for gub'mint work.
>
> So what we're trying:
>
> <CFTRY>
>
> <CFSWITCH etc etc>
> (all the stuff)
> </CFSWITCH>
>
> <CFCATCH> blah blah
> </CFCATCH>
> </CFTRY>
>
> and it doesn't seem to be catching any errors.
>
> Are there issues wrapping the switch(s) inside the
> try? Do we need to, in
> each of the includes that are fired up within the
> cases within the switches,
> do try/catch?
>
> Thanks in advance,
> --Scott
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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