Report insufficient permission errors
authorKarl O. Pinc <kop@karlpinc.com>
Thu, 29 Apr 2021 23:02:41 +0000 (18:02 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Thu, 29 Apr 2021 23:02:41 +0000 (18:02 -0500)
src/pgwui_upload_core/exceptions.py
src/pgwui_upload_core/views/upload.py

index 8025357dc8623fb7b68e526ad4ace065118119d0..ef173d885d83b9d1629654b56f5bff5d526d3daf 100644 (file)
@@ -65,3 +65,9 @@ class BadHeadersError(SetupError):
     '''The headers in the uploaded file are bad.'''
     def __init__(self, e, descr='', detail=''):
         super(BadHeadersError, self).__init__(e, descr, detail)
+
+
+class InsufficientPrivilegeError(SetupError):
+    '''The privileges are not sufficent to perform the requested operation'''
+    def __init__(self, e, descr='', detail=''):
+        super().__init__(e, descr, detail)
index dacd51dd6c7ce8b6d3450da391450f59a2afafb1..97459ad65384bf8ff0132b78252b7692ff85e2aa 100644 (file)
@@ -170,6 +170,10 @@ class BaseTableUploadHandler(TabularFileUploadHandler):
                     ('<p>Hint: Check spelling, database permissions, '
                      ' or try qualifying the'
                      ' table name with a schema name</p>'))
+            elif pgcode == psycopg2.errorcodes.INSUFFICIENT_PRIVILEGE:
+                raise upload_ex.InsufficientPrivilegeError(
+                    'Your PostgreSQL login has insufficient privileges',
+                    err.diag.message_primary)
             else:
                 raise
         return self.cur.fetchone()