Solved

cferror exception type using a database query to log errors

Posted on 2001-07-10
2
190 Views
Last Modified: 2013-12-24
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:

<html>
<head>
<title>We're sorry -- An Error Occurred</title>
</head>
<body>
<b><font face="verdana, arial, helvetica" size="3">We're Sorry. An Error Has Occured.</font></b>
<hr>
<cfoutput>
Sorry an error has occured. <a href="#mainpage#">Click here</a> to try continue.
</cfoutput>
<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#')
</CFQUERY>
</body>
</html>

I don't know what I'm doing wrong and I'm beginning to doubt that this can be done at all. Any comments?
0
Comment
Question by:kitten47
2 Comments
 
LVL 1

Accepted Solution

by:
Drewbytes earned 50 total points
ID: 6272463
If you are getting the error diagnostics, then there is most likely an error in your CFQUERY in errorpage.cfm. For example, if you comment out the CFQUERY, then you will see text from the file without the diagnostics, eg simialr to:

We're Sorry. An Error Has Occured.
--------------------------------------------------
Sorry an error has occured. Click here to try continue.

You only get the diagnostics if there is an error on the exception handling page (most likely in the query).

It will work if you comment out the query, then I'd suggest adding one field at a time to the CFQUERY until you determine which one is causing the problem.

Good luck.

0
 

Author Comment

by:kitten47
ID: 6275119
Thank you. It was because my Error.HTTPReferer was empty.
I was going directly to the page so there was no referrer URL.

For anyone else who might have this problem, here's the code I used to fix it:

<cfif Error.HTTPReferer is "">
     <cfset Error.HTTPReferer = "none">
</cfif>
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Script 12 154
Forbidden errors 5 141
CFFILE upload help 98 158
AWS Advice on using WHM/cPanel 1 74
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question