From afe3cb5906d2395323529fb2073e70ac7e90daac Mon Sep 17 00:00:00 2001 From: SJiB Date: Sat, 12 Oct 2024 15:37:23 +0200 Subject: [PATCH] Adapt errormessage on rollback_session --- qgepqwat2ili/gui/gui_import.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/qgepqwat2ili/gui/gui_import.py b/qgepqwat2ili/gui/gui_import.py index f933a2b9..499865b8 100644 --- a/qgepqwat2ili/gui/gui_import.py +++ b/qgepqwat2ili/gui/gui_import.py @@ -217,14 +217,19 @@ def refresh_editor(self, editor): self.stackedWidget.addWidget(editor.widget) self.stackedWidget.setCurrentWidget(editor.widget) - def rollback_session(self): + def rollback_session(self, emessage): self.session.rollback() iface.messageBar().pushMessage( "Error", "An error occurred: rollback_session activated!", level=Qgis.Warning ) - iface.messageBar().pushMessage("Error", "Import was canceled", level=Qgis.Warning) + if not emessage is None: + iface.messageBar().pushMessage("Error", f"An error occurred: {emessage}", level=Qgis.Warning) + iface.messageBar().pushMessage("Error", "Import was canceled", level=Qgis.Warning) + else: + iface.messageBar().pushMessage("Error", "Import was canceled", level=Qgis.Warning) + self.session.close() def commit_session(self): @@ -240,7 +245,7 @@ def commit_session(self): try: self.session.commit() except Exception as e: - self.session.rollback_session() + self.rollback_session(e) iface.messageBar().pushMessage("Error", f"An error occurred: {e}", level=Qgis.Warning) iface.messageBar().pushMessage("Error", "Import was canceled", level=Qgis.Warning) finally: