For transaction command to be effective, it is best to provide some unique identifier that ties events together eg: sessionid, userid, processid, guid etc. This helps transaction command group events more reliably. The startswith and endswith help better define boundary events within the transaction.
In you use case, it would be best to add a "transaction id". Regardless, you could add endswith="ERROR". This may give you what you are looking for.