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.