• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

9.3. Rethrowing Exceptions

Now that we've discussed the framework for building robust error- and exception-handling capabilities into your ColdFusion applications, let's look at a technique you can use to create more advanced exception handling systems for your applications. On occasion, it may be desirable to rethrow an exception that can't be handled adequately by a CFCATCH tag. For example, you may have a CFCATCH block that catches an error that it isn't explicitly designed to handle. In this case, it's desirable to rethrow the exception so that a more qualified error handler can deal with the exception. This can be accomplished using the CFRETHROW tag. The CFRETHROW tag is used within a CFCATCH block to rethrow the active exception while preserving the CFCATCH.Type and CFCATCH.TagContext return variables. This lets you build an additional level of decision making into your exception-handling routines.

To get a better idea of how the CFRETHROW tag can be used, consider an example in which you want to provide a backup data source to use in the event that a query to your main data source fails. This type of functionality is highly desirable in cases where your entire database is refreshed (i.e., in the case of an extract file) or when you use a file-based database such as MS Access or FoxPro where updating the database often means overwriting the production version with a new version. It is also a good idea when you just want to provide redundancy as you would in any sort of e-commerce or mission-critical application that requires 100% uptime.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint