I have inherited this huge application that has settings and configurations which took me a bit of time to figure out. One of these configurations was an error handling mechanism. This mechanism redirected to generic error pages whenever CF threw 404 or 500 server errors. Every time an error occurred I would need to manually wrap the corresponding file code in a try/catch block and dump the error object so that I could view the error details. As you would expect, this was tedious and unproductive.

The 1st thing that you should do in this case is check for the presence of try/catch blocks in the file itself. If there aren’t any, chances are that the error is probably being handled by an Application.cfc or application.cfm file somewhere in your current working directory or in the root folder. An Application.cfc file can have a cferror tag or an OnError method implementation to handle errors. An application.cfm file can have a cferror tag to handle errors. Neither of this was true in my case.

If neither of the two options are true in your case as well, then the next thing you can turn to are the Coldfusion Administrator settings. There is a particular setting here called Site wide error handler. If there is an error handler defined here then chances are that this must be what is handling your error and changes to this or disabling this can yield the desired results. In my case, this setting was not enabled.

Feeling helpless at this point, I googled around and found this excellent post from Raymond Camden. The article lists out the options mentioned above and more. He talks about another Coldfusion Admin setting called Enable HTTP status codes which should be turned on. If its not then try turning it ON and see whether this resolves the issue for you. In my case, this still didn’t resolve the issue.

So far, I checked the code and then checked Coldfusion Admin settings but I still did not find the source of the redirection. I decided to go up another level to the server which in my case was IIS. Try this out if you face a similar scenario. Open IIS Manager and in the Connections pane, select your site. Then select Error Pages from the adjacent window and see whether the error codes you need to change(in my case 500) is listed out here or not. I found an entry for the 500 status code here and it was redirecting to a local static HTML page. I deleted the entry and happily refreshed the page that was throwing the error hoping to see the full detailed CF error page but what I got was this.

Capture

(My Reaction)

via GIPHY

I decided to give it one last try and googled around a bit more and stumbled upon this SO answer which suggested taking a look at the web.config file. I looked and my httpErrors tag and it was formed something like this:

<httpErrors errorMode="Custom" />

As suggested in the answer, I changed this to this:

<configuration>
  <system.webServer>
    <httpErrors existingResponse="PassThrough" />
  </system.webServer>
</configuration>

Success at last! This worked for me and I started getting the default CF error messages.

Hope this helps someone trying to reverse engineer the error handling mechanisms implemented on an inherited application.

Thank you.

Share This