?
Solved

How to catch CF "File Not Found" Error

Posted on 2005-04-23
8
Medium Priority
?
3,974 Views
Last Modified: 2013-12-24
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
Comment
Question by:iqDevs
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 7

Expert Comment

by:INSDivision6
ID: 13852204
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
 

Author Comment

by:iqDevs
ID: 13852368
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
 
LVL 7

Assisted Solution

by:INSDivision6
INSDivision6 earned 200 total points
ID: 13852795
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 17

Expert Comment

by:anandkp
ID: 13854418
have a look at <CFERROR>

Also take a look at CFADMIN
CFADMIN -> Server Settings -> Settings -> Site-wide Error Handler
0
 

Author Comment

by:iqDevs
ID: 13854927
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
 
LVL 17

Expert Comment

by:anandkp
ID: 13856149
cant u get ur ISP to help u out with the CFADMIN ?
0
 
LVL 2

Accepted Solution

by:
BigSnazz earned 1800 total points
ID: 13862701
"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
 

Expert Comment

by:MFredin
ID: 33968447
OnMissingTemplate() works great for this.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

864 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