I'm trying to find an easy pattern to revert/rollback a write transaction.
The first idea was to log a GenericErrorEvent but then I noticed that it will never be emited if any require/revert/assert makes a "rollback".
On the truffle tests I can easily capture the errors within a try-catch, but an independent client listening for events would never be able to properly capture those same errors.
Since it's important to me that third clients can capture or listen for errors I'm just prechecking as much as possible in the function preconditions tests, log an error and just return from the public/external function if something goes wrong.
This works for simple scenarios but is very "manual" and changing the order of execution could actually introduce errors. Neither it allows to rollback from some error deeper in the stack once passed the first function precoditions.
I'm wondering whether there is a "magical" trick to log an error event and rollback to initial state with no manual coding.
The same question from another point of view:
Suppose we have next architecture:
JS client1 -> geth_node1 ... (ethereum net) ... geth_node2 <- JS Client2
JS Client1 sends a new signed transaction to its local node geth_node1. At some point the transaccion is processed by some mining node and the assert/revert/require is executed. There is a new mined transaction in the blockchain that spends a few weis from JS_client1 and JS_client1 will receive an string with the assert/revert/require error. Still, since no event is emmited JS_Client2 will have a hard time to be notified of such error.
It's it possible to (somehow) monitor at least all transactions signed by client1 and check when an assert/revert/require error was thrown?