Adobe ColdFusion 8

About error handling in ColdFusion

By default, ColdFusion generates its own error messages when it encounters errors. In addition, it provides a variety of tools and techniques for you to customize error information and handle errors when they occur. You can use any of the following error-management techniques.

  • Specify custom pages for ColdFusion to display in each of the following cases:
    • When a ColdFusion page is missing (the Missing Template Handler page)
    • When an otherwise-unhandled exception error occurs during the processing of a page (the Site-wide Error Handler page)

    You specify these pages on the Settings page in the Server Settings page in the ColdFusion Administrator; for more information, see the ColdFusion Administrator Help.

  • Use the cferror tag to specify ColdFusion pages to handle specific types of errors.
  • Use the cftry, cfcatch, cfthrow, and cfrethrow tags to catch and handle exception errors directly on the page where they occur.
  • In CFScript, use the try and catch statements to handle exceptions.
  • Use the onError event in Application.cfc to handle exception errors that are not handled by try/catch code on the application pages.
  • Log errors. ColdFusion logs certain errors by default. You can use the cflog tag to log other errors.

The remaining sections in this chapter provide the following information:

  • The basic building blocks for understating types of ColdFusion errors and how ColdFusion handles them
  • How to use the cferror tag to specify error-handling pages
  • How to log errors
  • How to handle ColdFusion exceptions

Note: This chapter discusses using the cftry and cfcatch tags, but not the equivalent CFScript try and catch statements. The general discussion of exception handling in this chapter applies to tags and CFScript statements. However, the code that you use and the information available in CFScript differs from those in the tags. For more information on handling exceptions in CFScript, see Handling errors in UDFs.