cferror exception type using a database query to log errors
Posted on 2001-07-10
My question is: is it possible to log errors to a database when redirecting an exception error to a template page using <cferror type="exception" ...>. From what I've read out on the net, it should work, right?
In my application.cfm file I have the entry:
<cferror type="exception" template="errorpage.cfm" exception="Expression">
The errorpage.cfm file has a database query that is supposed to log the error specifics to a database. However instead of making the database connection, it displays the error diagnostics from the page that threw the exception.
Here is the contents of errorpage.cfm:
<title>We're sorry -- An Error Occurred</title>
<b><font face="verdana, arial, helvetica" size="3">We're Sorry. An Error Has Occured.</font></b>
Sorry an error has occured. <a href="#mainpage#">Click here</a> to try continue.
<CFQUERY NAME="recordError" DATASOURCE="#datasrc#" DBTYPE="ODBC">
INSERT INTO Fatal_Errors(Location_ip, Browser, Occured, Referrer_URL, Page, Error_Msg)
VALUES('#Error.RemoteAddress#', '#Error.Browser#', '#Error.DateTime#','#Error.HTTPReferer#','#Error.Template#','#Error.Diagnostics#')
I don't know what I'm doing wrong and I'm beginning to doubt that this can be done at all. Any comments?