pgwui_core.exceptions.Error is now SetupError
authorKarl O. Pinc <kop@karlpinc.com>
Tue, 27 Apr 2021 20:33:28 +0000 (15:33 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Tue, 27 Apr 2021 20:33:28 +0000 (15:33 -0500)
src/pgwui_bulk_upload/exceptions.py
src/pgwui_bulk_upload/templates/bulk_upload.mak
src/pgwui_bulk_upload/views/bulk_upload.py

index 7a06eaea6bd49d8da35c92b256b3220c7d03ca7f..c34e24d9d4f94dda44bb7a90dfdf3ebb70010f6f 100644 (file)
@@ -20,6 +20,8 @@
 # Karl O. Pinc <kop@karlpinc.com>
 
 from pgwui_core import exceptions as core_ex
+# PGWUI setting related exceptions
+from pgwui_core.exceptions import SetupError
 
 
 # Line-by-line processing errors
@@ -32,22 +34,16 @@ class CannotReReadError(core_ex.DataLineError):
             f'The error is: {exp}')
 
 
-# PGWUI setting related exceptions
-
-class Error(core_ex.Error):
-    pass
-
-
 # Exceptions that require detail
 
-class NotAZipfileError(Error):
+class NotAZipfileError(SetupError):
     def __init__(self, filename):
         super().__init__(
             'No zip file uploaded',
             f'The uploaded file ({filename}) is not recognized as a zip file')
 
 
-class CannotUnarchiveError(Error):
+class CannotUnarchiveError(SetupError):
     def __init__(self, filename, err):
         super().__init__(
             'Cannot unzip',
@@ -55,7 +51,7 @@ class CannotUnarchiveError(Error):
              'the error reported is: err'))
 
 
-class NotADirectoryError(Error):
+class NotADirectoryError(SetupError):
     def __init__(self, filename, name):
         super().__init__(
             'Not a directory',
@@ -64,14 +60,14 @@ class NotADirectoryError(Error):
             'The entries at the top of the zip file must be directories')
 
 
-class EmptyArchiveError(Error):
+class EmptyArchiveError(SetupError):
     def __init__(self, filename, err):
         super().__init__(
             'Empty zip file',
             f'The uploaded file ({filename}) has no content')
 
 
-class NotAFileError(Error):
+class NotAFileError(SetupError):
     def __init__(self, filename, name):
         super().__init__(
             'Not a file',
@@ -80,7 +76,7 @@ class NotAFileError(Error):
             'The directories in the zip file may only contain files')
 
 
-class NoMapfileError(Error):
+class NoMapfileError(SetupError):
     def __init__(self, filename, map_file):
         super().__init__(
             'Missing map file',
@@ -90,14 +86,14 @@ class NoMapfileError(Error):
             'maps file names to table names')
 
 
-class CannotReadError(Error):
+class CannotReadError(SetupError):
     def __init__(self, filename, exp):
         super().__init__(
             f'Cannot open ({filename}) for reading',
             f'The error is: {exp}')
 
 
-class CannotRollbackError(Error):
+class CannotRollbackError(SetupError):
     def __init__(self, exp):
         super().__init__(
             'Cannot roll back the current transaction',
@@ -107,7 +103,7 @@ class CannotRollbackError(Error):
             f'The error from psycopg2 is: ({exp})')
 
 
-class BadMapFileError(Error):
+class BadMapFileError(SetupError):
     pass
 
 
index ada7b8d7648dd7e889ff159f618f7bc4030d91a0..453ca7bf8e785cf2a778d7b5696fc66d79e1b597 100644 (file)
@@ -31,7 +31,7 @@
 <%!
     from pgwui_upload_core.template_utils import show_choice
     from pgwui_common.path import asset_abspath
-    import pgwui_core.exceptions as core_ex
+    import pgwui_common.exceptions as common_ex
 
     upload_base_mak = asset_abspath('pgwui_upload_core:templates/upload.mak')
 %>
@@ -93,7 +93,7 @@
       last_filepath = None
       f_errors = []
       for error in errors:
-          if isinstance(error, core_ex.UploadError):
+          if isinstance(error, common_ex.UploadError):
               if error.filepath != last_filepath:
                   if last_filepath:
                       self.file_errors(f_errors, last_filepath, firsterr)
index c456908df2ee09cc1a691d811d4eb9ad468b4beb..922ba1a17556ef1a24223b0d27e478452d9f1e6e 100644 (file)
@@ -419,7 +419,7 @@ class UploadArchive():
                 try:
                     # Every file consumes a header line
                     self.lineno += updir.open(zip_root / dentry.name)
-                except ex.Error as exp:
+                except ex.SetupError as exp:
                     err_tups.append((dentry.name, exp))
                 except core_ex.MultiError as exp:
                     err_tups.extend([(dentry.name, err) for err in exp.errors])