• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3993
  • Last Modified:

How to catch CF "File Not Found" Error

Howdy,

I'm looking to catch the error that coldfusion MX 7 throws when a file is not found on the server. Please note that this is not a CFINCLUDE error. This is when a filename was perhaps misspelled in the URL. I would like to catch this error and run a particular page instead of the standard error the CF outputs.

My CF hosting service does not give me full access to the CF administrator control panel, so I was hoping there was something nifty I could do in application.cfm or something like that. If it can be done only in CF admin, I would at least like to know what settings have to be set in order for this to work properly.

Thanks,
Travis
0
iqDevs
Asked:
iqDevs
  • 2
  • 2
  • 2
  • +2
2 Solutions
 
INSDivision6Commented:
Sounds like you want catch 404 HTTP error?  Dependently on the Internet server you are running, you can set a page that is being called when "file not found" condition is encountered, instead of default error page.  If you provide a ".cfm" page, you will be able to do something, when this error occurs.

0
 
iqDevsAuthor Commented:
Its actually not a 404 HTTP error, its a CF error.

For example, if you were to go to http://www.iqdevs.net/howdy.html you would get a 404 HTTP error (which i know how to handle with my server). However, if you go to http://www.iqdevs.net/howdy.cfm you run into a CF "Error occured while processing request" error. Follow those links to see it. Neither howdy.html nor howdy.cfm exist on the server.
0
 
INSDivision6Commented:
In MS IIS you just need to select option "Check that file exists" to prevent execution of IIS extension.  There could be similar option in Apache you running.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
anandkpCommented:
have a look at <CFERROR>

Also take a look at CFADMIN
CFADMIN -> Server Settings -> Settings -> Site-wide Error Handler
0
 
iqDevsAuthor Commented:
I've used <CFERROR>, unfourtunately, <CFERROR> only catches Exception errors.

Did a little research of at livedocs.macromedia.com. Apparently there are 3 basic types of errors: (1) Exceptions, (2) Missing template errors, and (3) Form field data validation. My error is number 2, the missing template error. Unfourtunately, cferror will not catch this. I tried using cferror with all its different types w/o any luck.

From what i have read, i'm thinking the only solution to this problem is to go thru CFADMIN (which i don't have access to).
0
 
anandkpCommented:
cant u get ur ISP to help u out with the CFADMIN ?
0
 
BigSnazzCommented:
"In MS IIS you just need to select option "Check that file exists" to prevent execution of IIS extension.  There could be similar option in Apache you running."

Short of being able to have access to the CF Administrator and specifying a site-wide error handler, this is going to be your best solution.  The problem is that your ISP's web server is handing the request off to ColdFusion without first checking to see if the file in question exists.  The first thing CF checks for is the existence of the file, and it throws an error immediately without executing a single line of code.  There's nothing you could put in your Application.cfc file that would catch the error, as it would not be executed.

If you can get your ISP to select the "Check file exists" option (or whatever the equivalent is in their web server software), you can also probably get them to specify a custom 404 error handler for you.  At that point, you can do anything you like when someone types a bad URL.
0
 
MFredinCommented:
OnMissingTemplate() works great for this.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now