So something like
<#
GiveError("Something is not right");
#>
which would then show as compilation error in the error list among the other compilation errors. This could be helpful to provide the programmer with more specific information about what is going wrong, instead of just exiting with a ErrorGeneratingOutput
message in the target file.
I don't know anything about T4 generation specifically, so I can't help in terms of halting the generation process with a useful message, but you may find it's better just to generate a #error
pragma, e.g
#error No configuration found for X
Ideally the rest of the file should still be valid (or have more error reports) so that you end up with just the errors you want to report.
One benefit of this over halting is that if there are multiple problems to fix, the developer may be able to fix them all in one pass. The downside is that (depending on what you're generating) a single configuration problem may cause thousands of errors, unhelpfully.
See more on this question at Stackoverflow