Subclass "runtime" exceptions
authorKarl O. Pinc <kop@karlpinc.com>
Mon, 19 Aug 2024 23:44:47 +0000 (18:44 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Mon, 19 Aug 2024 23:48:56 +0000 (18:48 -0500)
src/pgwui_sql/exceptions.py
src/pgwui_sql/views/sql.py

index e90679387a644846c6f7278cb686859db59d4a63..b6391ae226231d2b626ff6462e467beb7e4db60f 100644 (file)
@@ -51,7 +51,17 @@ class SQLError(core_ex.UploadError):
     e      The error severity
     descr  More description of the error
     detail Extra HTML describing the error
-    data   The uploaded data
+    '''
+    def __init__(self, e, lineno, descr='', detail=''):
+        super().__init__(e, lineno, descr=descr, detail=detail)
+
+class ExecutionError(SQLError):
+    '''
+    Error raised when processing SQL
+
+    e      The error severity
+    descr  More description of the error
+    detail Extra HTML describing the error
     '''
     def __init__(self, e, lineno, descr='', detail=''):
         super().__init__(f'{e} when executing SQL',
index 2c29db8689aa1b044ed6e6472b743b4d6abff54a..dc75dfc9360e0b33ed35a4a08ab211e7813d3b9b 100644 (file)
@@ -174,10 +174,11 @@ class SQLHandler(pgwui_core.core.SessionDBHandler):
         except psycopg.errors.Error as err:
             lineno = stmt_text.count(
                 '\n', 0, int(err.diag.statement_position) - 1) + 1
-            raise sql_ex.SQLError(err.diag.severity,
-                                  lineno,
-                                  descr=err.diag.message_primary,
-                                  detail=self.format_detail(err, stmt_text))
+            raise sql_ex.ExecutionError(
+                err.diag.severity,
+                lineno,
+                descr=err.diag.message_primary,
+                detail=self.format_detail(err, stmt_text))
 
     def get_result_rows(self, cur):
         rows = []