fix: handle error when merging 2 records fails

should give the user some idea of the problem instead of just sending
error email to admins
This commit is contained in:
Lance Edgar 2024-06-28 15:36:08 -05:00
parent 067ca5bd43
commit 3b7cc19faa

View file

@ -2292,9 +2292,13 @@ class MasterView(View):
except Exception as error:
self.request.session.flash("Requested merge cannot proceed (maybe swap kept/removed and try again?): {}".format(error), 'error')
else:
self.merge_objects(object_to_remove, object_to_keep)
self.request.session.flash("{} has been merged into {}".format(msg, object_to_keep))
return self.redirect(self.get_action_url('view', object_to_keep))
try:
self.merge_objects(object_to_remove, object_to_keep)
self.request.session.flash("{} has been merged into {}".format(msg, object_to_keep))
return self.redirect(self.get_action_url('view', object_to_keep))
except Exception as error:
error = simple_error(error)
self.request.session.flash(f"merge failed: {error}", 'error')
if not object_to_remove or not object_to_keep or object_to_remove is object_to_keep:
return self.redirect(self.get_index_url())