Tutorial on debugging a CFML page?

One of the constant bugbears with CFML is the horrible way it gives the most basic debugging information. For example if I make a syntax error - say something simple like a missing terminating # symbol… The error message it gives me is hundreds of lines long, but the clue I see is “missing terminating [#] for expression::”

Lucee’s error page gives me the file name. It gives me the line number - but not the line number where the error is, it gives me the line number of the page that called this page. The only way I’ve found to find this simple error is to laboriously go down the offending page, checking every variable looking for the missing hash.

I can find the errors and they’re easy to fix - that’s not the problem. But what I’d like is a hint as to where to look for the offending line.

This is awful to admit but i’ve been writing CFML for 26 years now and its only now i get around to asking if anyone’s got a better way to find tiny (but crucial) errors like missing semicolons or quotes or something like that. As my vision has deteriorated over hte last few year it’s now up to about half my time developing an app.

Mike Kear
Windsor, NSW, Australia

/me raises eyebrow.

Invalid Syntax Closing [#] not found
Stacktrace	The Error Occurred in
/var/www/test/tagUsageAnalysis.cfm: line 31
29: line = 1;
30: for (tally in sortedTally){
31: writeOutput("#line: #tallies[tally]# (#tally#)<br/>");

It tells me what the problem is and where it is. And - not clear from my copy and paste - it boldens the exact line where the error is (I took the closing # from #line# out).

I’m not sure what more clarity yer after?

Can you give us an example of an error message you are finding hard to assess? Not a description of one, give us the actual error. NB: poss make a gist instead of pasting it inline here, given with all the stack trace they get quite big.

Thank you Adam, that’s what i was wanting to see. But I’m not getting that at all. I get a page with hundreds of lines of gobbledegok and the line on the page that called this one with the error, and the first line - that it’s a missing closing hash. If i knew how to get a look at what you’ve just shown me that would be precisely what i need.

Without that extra location info my only choice is to start at the top of the page, which sometimes has 200 lines of code in it - for a long cfc for example and i have to laboriously go down the page line by line looking for a missing hash. Very tiresome. Specially when i’m fighting a cataract in my one working eye.

in stacktrace, i see this stuff:
lucee.runtime.exp.CustomTypeException: Bean creation exception in Core.cfcs.codegen.tables.BuildEDITPAGE at ucee.runtime.tag.Throw._doStartTag(Throw.java:212) at lucee.runtime.tag.Throw.doStartTag(Throw.java:201) at coldspring.beans.beandefinition_cfc$cf.udfCall3(/coldspring/beans/BeanDefinition.cfc:573) at coldspring.beans.beandefinition_cfc$cf.udfCall(/coldspring/beans/BeanDefinition.cfc) at …

and that goes on for another 88 lines

By the way, this isn’t anything new - its been that way since i was learning CFML with ColdFusion 4,5 It’s only now that my eyesight has got so poor that i dont see typos without going back over my work carefully and syntax errors just take up so much time to fix now even though when i eventually find the location it’s usually 2 or 3 seconds to fix it. Commas and fullStops are particularly nasty because the double vision i work with makes them look the same as each other. Same with colons and semicolons.

Mike Kear
Windsor, NSW, Australia.

That is just the default behaviour.

if you’re seeing something different, then… well… that’s cos you are doing something different. Yer code is intercepting errors and doing something with them, or you’ve replaced the default error template with a different one, or [I dunno].

I asked you to include the entire error (as a gist or pastebin or something), but you have declined to do that, so not sure what else to say.

I have been using chatgpt to find errors like that when the debug info doesn’t identify the line. Just paste the entire page of code into chatgpt and ask it to give errors

I havent declined. There’s no reason i’d decline to tell you what you need to know to help me. But it’s a couple of hundred lines long I’m not sure how to post that on here. How do i post code here anyway?

I’ll try bold this time around.


HI Mike

This is an issue with ColdSpring (not specifically) as it does a lot of dynamic instrospection at runtime. So the syntax error is discovered at runtime rather than “compile” time (which is kinda one in the same with lucee) when you would discover syntax errors.

One way we check for syntax (brute force approach) ist to do a lucee compilation of the mapping. Here is some code for that:

admin action="updateMapping" password="#password#" archive="" primary="false" virtual="/" physical="path to your sourcecode";
admin action="compileMapping" password="#password#" virtual="/" stoponerror="false" returnVariable="res";
admin action="removeMapping" password="#password#" virtual="/";

The code above creates a root mapping, compiles it and will throw an error if there are syntax errors.

Hopefully this helps!

Thank you Mark - that’s a little corner of Lucee i had never heard of before. I"ll check it out. What password in is that in the code? Is that the Lucee server administrator password?