Skip to content

Commit

Permalink
Adapt errormessage on rollback_session
Browse files Browse the repository at this point in the history
  • Loading branch information
sjib committed Oct 12, 2024
1 parent 2e797f2 commit afe3cb5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions qgepqwat2ili/gui/gui_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down

0 comments on commit afe3cb5

Please sign in to comment.