3 Replies Latest reply on Sep 20, 2006 1:10 PM by Swift

    Calling the experts

      Hi all,

      I think I might be trying to use CFReThrow in a manner that it wasn't intended.

      On our site we have a page tracking system we call PageHistory. Every page that is requested is entered into a server scoped array when it starts (i.e. in the application.cfm), and the array item is then updated at the end of the request (OnRequestEnd.cfm) with the end time and duration. It has enabled us to write a nifty Activity Monitor, that is an almost real-time look at who is accessing our program, and what pages they accessed (plus the form fields and any query string used - essential for investigative purposes). The one drawback we had is when a page errors out we would have an open PageHistory record that we would automatically close after an hour. We've had trouble matching up errors to our page history when we have been tasked with fixing them. We need the page history to enlighten us with how the user got the error - exactly what they must have clicked on to get it - so we can reproduce it.

      So, I thought I could simply put in an error template to ensure that it closes the PageHistory record for us correctly. It worked great. Then I decided that I wanted to see the normal ColdFusion error that we've been seeing whenever an error occurs (yes, the normal CF error is what is presented to the user - I know that's bad, and even why it is - let me just say that the client doesn't always listen). I thought I could simply do a <CFRethrow> to accomplish that task. I added it in, and yes it did show the original error on the screen, but what it didn't do is update my server scoped page history array with the error status for the page, and the error diagnostics.

      If I comment out the CFRethrow and run my test page with an intentional error, my page history runs fine and updates the array with the error, if I put it back in, then I get left with an Open record - the status doesn't get changed.

      It's almost like the Rethrow performs a "transaction rollback" taking out whatever changes the CF code might have made... but surely not, right?

      Any ideas would be greatly appreciated.


      P.S. I have attached my ErrorHandler.cfm template. The OnRequestEnd is what contains the PageHistory.cfm code include, among other things.