Solved

cferror exception type using a database query to log errors

Posted on 2001-07-10
2
192 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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