Allow exception error descriptions to be extended
authorKarl O. Pinc <kop@karlpinc.com>
Fri, 25 Dec 2020 21:01:47 +0000 (15:01 -0600)
committerKarl O. Pinc <kop@karlpinc.com>
Sat, 2 Jan 2021 19:56:58 +0000 (13:56 -0600)
src/pgwui_core/exceptions.py

index dc89a4c9d6b36b0f0bfd28bfd261e9a82d4c4c63..ea618ed6f12cd6aed91e967f7df3dba34b4114df 100644 (file)
@@ -64,6 +64,8 @@ class UploadError(PGWUIError):
         self.descr = descr
         self.detail = detail
         self.data = data
+        self.filepath = None
+        self.relation = None
 
     def __str__(self):
         out = 'error ({0})'.format(self.e)
@@ -77,6 +79,14 @@ class UploadError(PGWUIError):
             out = '{0}: data ({1})'.format(out, self.data)
         return out
 
+    def color(self, descr, filepath, relation):
+        '''Add a description to the exception's error and save filepath
+        and relation
+        '''
+        self.e = f'{descr}: {self.e}'
+        self.filepath = filepath
+        self.relation = relation
+
 
 class Error(UploadError):
     '''