views:

44

answers:

1

In my Application.cfc, I have an onError function that works great for all errors except when the page being called has a missing closing tag. The error being thrown is InvalidEndTagNestingConfigurationException. I would like to catch these types errors as well in the application.

Why doesn't onError catch a missing closing tag error? Is there a way to catch these errors?

Thanks!

+5  A: 

The reason these types of errors are not caught by onError is that its a compile error - the CF parser can't even compile the template to classes to run them, so Application.cfc hasn't even run at the time the error is thrown.

These should never ever really happen, because you should have tested the code before it ever went live ;)

The best way to make sure that this doesn't happen is to use the cfcompile to pre-compile your source to find any of these compile-time errors. The compiler will report any compile-time errors. Its efficient, as well, as it will only re-compile templates that have changed, so it takes very little time after the first time.

If you use Eclipse (well, even if you don't), then you can set up an Ant task that makes this easier - and you can even make it a pre-commit action before you commit code to your source control repository.

Edward M Smith
Thanks never knew there was such a thing as cfcompile
Pragnesh Vaghela