Solved

cferror exception type using a database query to log errors

Posted on 2001-07-10
2
188 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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now