Two first response thoughts.
Is there any difference at all in the DETAIL template trap possibilities that would allow you to identify the records you want but skip the Error records? Could you add to the trap or maybe even take something away?
If not possible at that point the next idea is to trap as you have at the detail level but add an append template (if you don't already have one) that captures the ERROR header. Is there a comparable header, even an empty one, that could be trapped for the non-error records?
If you can include a field that identifies which section the records come from you can apply a filter that, for display/output, retains only the record section(s) you want to keep.
If those ideas don't work out for you we can dig a little deeper ...
Hello Ruby, hello Grant,
One of the most horrible spool files I ever saw came from a mainframe with multiple reports all just poured into one file, sometimes overlapping or intermingled with each other. Even before Monarch v10 and the "turn off append", it was possible to fix it.
On option you could explore is Page Header - but you need your data to behave nicely in chunks of less than 256 lines. You can sometimes get some structure into your data by trapping what look like headers as detail in one model, and tying them back to the corresponding detail records via an external lookup with Page() as the join key.
Otherwise Grant's Append suggestion is more flexible. Does your data start with "good" records, then have some "bad" ones, then go back again to having "good" ones? Are there duplicates? Would it be easier if the whole file was turned upside down (easy to fix in a script)? How automated do you need the solution to be?