cferror and Exceptions


<cferror> and Exceptions

Earlier in the chapter, you learned about <cferror> with the type attribute equal to Request and Validation. Now that you've learned about exceptions, you can extend the use of <cferror>.

<cferror type="exception">

The <cferror> tag directs program execution to a designated error template when the type is Request or Validation. The information from the error template is displayed, and program processing ends. The same is true when the type is Exception, except that on the error template, you have access to the full set of ColdFusion tags, as well as the <cferror> variables as needed.

If you do not specify an exception type using the exception attribute, the default is Any, so any exception that occurs is directed to the error template. You can also use multiple <cferror> tags in Application.cfm as follows:

 <cferror type="Exception"          template="ExpressionTemplate.cfm"          exception="Expression"> <cferror type="Exception"          template="DatabaseTemplate.cfm"          exception="Database"> 

This code directs exceptions of type Expression to one template, and of type Database to another.

TIP

You might think that you don't need <cferror> with type Request if you are using type Exception. This is not true. The Request template is used if an exception occurs on the template specified with the type equal to Exception.




Macromedia ColdFusion MX 7 Certified Developer Study Guide
Macromedia ColdFusion MX 7 Certified Developer Study Guide
ISBN: 0321330110
EAN: 2147483647
Year: 2004
Pages: 389
Authors: Ben Forta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net