Catch only the exceptions we expect to be raised
authorKarl O. Pinc <kop@karlpinc.com>
Thu, 14 Jan 2021 03:54:27 +0000 (21:54 -0600)
committerKarl O. Pinc <kop@karlpinc.com>
Thu, 14 Jan 2021 03:54:27 +0000 (21:54 -0600)
src/pgwui_bulk_upload/views/bulk_upload.py

index b2c0a4eaba5d6fc7411c3ebeac8a464b5ae4e077..b897fd57ce185201348ac595c23345948a751881 100644 (file)
@@ -111,13 +111,14 @@ class SaveBulkLine(DataLineProcessor):
         filepath = data.filepath
         try:
             udl = thunk()
-            self.cur.execute(
-                self.insert_map[filepath], udl.tuples)
         except (core_ex.DataLineError, core_ex.DBError) as exp:
             relation = data.relation
             exp.color(map_description(filepath, relation),
                       filepath, relation)
             raise exp
+        try:
+            self.cur.execute(
+                self.insert_map[filepath], udl.tuples)
         except psycopg2.DatabaseError as exp:
             relation = data.relation
             myexp = core_ex.DBDataLineError(udl, exp)