[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

cferror exception type using a database query to log errors

Posted on 2001-07-10
2
Medium Priority
?
197 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

872 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