Andrea MoroIl blog di

How to enable the robust debug info on your ColdFusion web application

There are so many elements that constitute the WWW: server infrastructure, operating systems, connection type, programming languages and so on.
With regards of the programming languages, it is inevitable talking about the HTML, which in any case is the “definitive” language that allows a web page to be laid out.
What probably not many programmers or geeks know is that HTML can be pre-saved as a static file, or built on the fly thanks to server-side technologies.
These technologies are basically made by an engine that interprets a series of instructions (source code) to generate the final HTML to be sent out as a response to the client request. I don’t want to enter into particular regarding the usefulness of using a server-side technology, rather help my friend Merlinox to spread the voice around an interesting way he found to allow ColdFusion to return all the information regarding the exceptions.

While coding, in fact, it is inevitable to stick into the source errors that compromise the stability and the performance of a web application.
And the only way to discover these bugs is testing and of course having a decent response from the server, which may help the developer to discover the cause of the malfunctioning.

A powerful language with the broken legs

With this regard, Coldfusion is a very powerful web language, as among the other thing it allows programmers to have a very detailed number of debugging information (server variables statuses, client variable statuses, stack trace etc.).
As these details are too many, it is likely on a shared enviroment hosting providers to lock what is known as the “robust debug”.
So the point is, how we can do to obtain essential debug info we need to fix the bug in the ColdFusion application in this scenario?

Enable a robust exception information on ColdFusion

To enable robust exception information in the scenario above, we can go back in time and use  an old trick to be sent via email.
A couple of lines is all you need.

Let’s start with the Application.cfm file, by adding the following:

<cferror type="EXCEPTION" template="error.cfm">

The next step is to add whatever information you need in the “error.cfm” file. It would probably be more important to send the full “error” variable structure that contains all the information you need.

To achieve this, the following lines are required:
<cfdump var=”#error#”>
<!— (if exists) —>
<cfdump var=”#form#”>
<cfdump var=”#url#”>
<cfdump var=”#session#”>
<cfdump var=”#cgi#”>

A bit of security is required indeed

It’s not good practice publishing the full error stack to everyone. Therefore, it is recommended to include the cferror tag between a decisional pattern.
For example, if you work on a computer with a dedicated connection and a static IP address, you can limit the send only if you are the developer and you are working on a specific computer. That’s the preferable method, and if you like it, what you need to do is surrounding the code aforementioned with the following lines:
<cfif cgi.remoteAddr is “***.***.***.***”>
<cferror type=”EXCEPTION” template=”errorEmail.cfm”>
</cfif>
Technorati Tags: ColdFusion, robust debugging


Leave a Reply

gosq