In your Application.cfc, employ the onMissingTemplate() function which will execute when a template is not found. You can put your custom code handling in there.
More info: https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/onmissingtemplate.html