Copy link to clipboard
Copied
I was playing around with different ways to set cookies and in the process I use the cfcookie tag wrong. It threw an error and the onError() sort of did its job. Rather than giving a nice clean error like normal, the page completely quit processing.
So I played around some more and tried this with out an onError() in the application.cfc.
<cftry>
<cfset asdf = />
<cfcatch type="any">
<cfdump var="#cfcatch#">
</cfcatch>
</cftry>
It threw the error as if the try/catch wasn't there. Is this normal and it has taken me years to notice it?
Phil
The behaviour you observe is the expected, and correct, one. The purpose of try/catch and onError is to catch exceptions.
ColdFusion compiles pages into executable code before running them. Strictly speaking, exceptions are errors that occur when ColdFusion runs already compiled CFML (CFM and CFC) pages.
However, what happens when Coldfusion finds errors, for example, programming and syntax errors, during compilation? Such errors occur before ColdFusion converts the code to executable form. You t
...Copy link to clipboard
Copied
The behaviour you observe is the expected, and correct, one. The purpose of try/catch and onError is to catch exceptions.
ColdFusion compiles pages into executable code before running them. Strictly speaking, exceptions are errors that occur when ColdFusion runs already compiled CFML (CFM and CFC) pages.
However, what happens when Coldfusion finds errors, for example, programming and syntax errors, during compilation? Such errors occur before ColdFusion converts the code to executable form. You therefore cannot use try/catch or onError to handle them.
Coldfusion will report the errors that it finds during compilation as compiler errors. That is what happens in your example. The line
<cfset asdf = />
contains a programming error and so won't even compile. That is why you get a compiler error.
If you replace it with the line,
<cfset asdf = 2/0 />
you will get code that compiles, but which generates an exception.
Copy link to clipboard
Copied
I think the 3 60+ hour work weeks managed to shut down the part of my brain with 15+ years of CF development experience. Plus I got some sleep which always helps.