The challenge here is that depending on what the error is and the scope of it, it may be significant enough to prevent WHMCS from being able to initialise and process a template for output. An error early in runtime such as in a hook file as per your suggestion is one example of such a scenario. It is for this reason that some early and blocking error conditions cannot use templates for their output while others will use the templates you see in the templates directory.