AlertError is just an Alert (MessageBox) with an “error” icon. It is not intended to stop execution.
In a GUI program, “stopping” is not quite the same as in straight procedural code. e.g. if you are in a button handler, you can just return to not do anything further for that button press.
To roll back database changes, you need to be inside a transaction. (And database changes must be specifically associated with that transaction in order to be rolled back.)
If you use the “block” form of Transaction and the code throws an exception, then the transaction is automatically aborted and the changes rolled back.
I hope that helps.