|
DescriptionRethrows
the currently active exception. Preserves the exception’s cfcatch.type and cfcatch.tagContext variable
values.
UsageUse this
tag within a cfcatch block. This tag is useful
in error handling code, if the error handler cannot handle an error
that it catches. For example, if cfcatch type = "any" gets
a DATABASE exception, and the code is designed to handle only CFX
exceptions, the handler raises the exceptions again, with details
intact, so that a higher-level handler can process the error information.
If you used the cfthrow tag, the type and details
of the original exception would be lost.
Example<h3>cfrethrow Example</h3>
<!--- Rethrow a DATABASE exception. --->
<cftry>
<cftry>
<cfquery name = "GetMessages" dataSource = "cfdocexamples">
SELECT*
FROM Messages
</cfquery>
<cfcatch type = "DATABASE">
<!--- If database signalled a 50555 error, ignore; otherwise, rethrow
exception. --->
<cfif cfcatch.sqlstate neq 50555>
<cfrethrow>
</cfif>
</cfcatch>
</cftry>
<cfcatch>
<h3>Sorry, this request can't be completed</h3>
<h4>Catch variables</h4>
<cfoutput>
<cfloop collection = #cfcatch# item = "c">
<br>
<cfif IsSimpleValue(cfcatch[c])>#c# = #cfcatch[c]#
</cfif>
</cfloop>
</cfoutput>
</cfcatch>
</cftry>
|
|
|