CF Snippets

Global Error Logging from Application.cfc

The onError function in Application.cfc is a great way to catch errors within your application and make sure that each error is logged. Be aware that if you catch an exception within your app, that exception will not "bubble up" to this onError handler unless you also use rethrow.

// Application.cfc
component {
  // ...
  function onError( exception ){
   // Log it with LogBox!
    writeOutput( "Logging error with logbox..." );
        "Error in cfSnippets app: #exception.message# #exception.detail#"

    // show error page
    include "views/error.cfm";