Python - Undo script if script fails
You could enable Undo support for your operator. Below

bl_label = "Simple Object Operator"


add

bl_options = {'REGISTER', 'UNDO'}


But I wouldn't make the operator undo itself on errors, rather let the user do it if necessarily. However, your script shouldn't raise exceptions in the first place, but check in the operator's poll() classmethod, if all pre-conditions are met. Or let it return {'CANCELLED'} inside the execute() body before something is damaged.