Linking To Files In ColdFusion Errors

Its been well over a year ago that I dropped developing with CFEclipse. I grew tired of the endless resources it consumed and it always seem very slow. Of course this wasnt due to the the CFEclipse plugin, it was the Eclipse platform that it was built on. Now with Adobe releasing the beta of ColdFusion Builder I decided I would give it a try again. But after an hour or so of playing with it, I still wasnt sold.
So, it was back to Textmate for me. Using Textmate for devlopment has been a pure joy. Its so easy to add new functionality specific to the language you are using with its Bundles that I find myself looking for new ways to make everything faster. I have created a bundle for CFWheels that provides function insight along with snippets for just about everything in the framework. This runs on top of the excellent ColdFusion Bundle that Rob Rohan is working on. I have hotkeys for just about everything I need with the exception of getting me another cup of coffee.
I have heard from guys on mailing lists time and time again talk about the productivity they have gained since moving to Textmate or its port to Windows called “E-Texteditor”.
I came across a feature in the Textmate manual yesterday that I was interested in and wanted to see if I could exploit it in some way. This feature was the ability to link directly to files on your dev machine from other applications, even in html. Hmmm, so does this mean I could create an error page that would link directly to my development files?
So, since I use Railo for my local development mainly, I opened up the web admin and found the Error section to see which error file I was using for this particular project. I was using the error-neo.cfm template that mimics the output of the ColdFusion error pages, so I opened it up in Textmate to see how the file list was output.
Now Im not going to gaurantee that the ColdFusion error code is the same as the Railo error code but its probably pretty similar and should work just as well. So this is what I found for the error output:

The error occurred in #catch.tagcontext[idx].template#: line #catch.tagcontext[idx].line#
Called from #catch.tagcontext[idx].template#: line #catch.tagcontext[idx].line#

Wow, that looks simple enough. So back to the Textmate documentation I went to see exactly “how” I build out the link structure. The URL structure in HTML is pretty simple. There are only 3 parts to it that you have to build out.

  • url – the (file) URL to open
  • line – the line number to jump to an place the cursor when the file is opened
  • column – the column to place the cursor when the file is opened

Now going back and looking at our error code. We know the code is outputting the full path to the file and its also displaying the line number. So we have 2 of what we need. The Column attribute is optional and we dont really need it.
So here is what our link should actually look like using the Textmate format and our CFCATCH variables:


Pretty simple right? Now here is the same code block with the URL’s in-place to allow you to open any of the files in the error stack.

The error occurred in #catch.tagcontext[idx].template#: line #catch.tagcontext[idx].line#
Called from #catch.tagcontext[idx].template#: line #catch.tagcontext[idx].line#

Now when you encounter an error in your application and the cfcatch message is displayed with the file listing. You can simply click on the file and it will open to the exact line in Textmate. No digging through the file list to find the file.

3 thoughts on “Linking To Files In ColdFusion Errors”

  1. I can see that being an issue for some people I guess. It took me a little while to get used to typing the tag or function name and then hitting the TAB key to auto-complete the code for me. But once I got used to it, it seems faster for me. I tried coding in CFBuilder the other day and I couldn’t get used to it again. Seemed way too unproductive for me.

  2. Well I am a bad typer of course and my desk is pretty tall so my hands aren’t at a good typing position for shortcuts. I just wished it would code complete like every other browser.

  3. I just can’t get the hang of textmate, I’m not into key shortcuts and having to type 90% of a tag for it to auto-complete drives me nuts. I do like it for system files and server files but I always end up going back to coda.

Leave a Reply

Your email address will not be published. Required fields are marked *