Fix flake8 style problems and provide a core exception example
authorKarl O. Pinc <kop@karlpinc.com>
Fri, 22 Mar 2024 21:21:14 +0000 (16:21 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Fri, 22 Mar 2024 21:21:14 +0000 (16:21 -0500)
src/pgwui_develop/TEMPLATE/src/pgwui_TEMPLATE/exceptions.py.mak

index 70fd33ef30f78442f0b21b39ee8030eeeb5e6d1a..f1aa67b7c457e15e0bee7137b12f8d756e02b8ec 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 The Meme Factory, Inc.  http://www.karlpinc.com/
+# Copyright (C) 2020, 2024 The Meme Factory, Inc.  http://www.karlpinc.com/
 
 # This file is part of ${component}.
 #
@@ -23,18 +23,39 @@ from pgwui_common import exceptions as common_ex
 from pgwui_core import exceptions as core_ex
 
 
-# PGWUI setting related exceptions
+# PGWUI setting and user-supplied value related exceptions
 
-class Error(common_ex.SetupError):
+class ExampleSetupError(common_ex.SetupError):
     pass
 
 
-class ExampleOnOffAskError(SetupError):
+class ExampleOnOffAskError(ExampleSetupError):
     def __init__(self, value):
         super().__init__(
-            'The "pgwui:${component}:example_on_off_ask" PGWUI setting '
-            ' must be "on", "off", "ask", or not present')
+            ('The "pgwui:${component}:example_on_off_ask" PGWUI setting '
+             ' must be "on", "off", "ask", or not present'),
+            descr=f'Got: ({value})')
 
-class ExampleDetailedError(SetupError):
+
+class ExampleDetailedError(ExampleSetupError):
     def __init__(self, e, descr='', detail=''):
         super().__init__('Detailed error', descr=descr, detail=detail)
+
+
+# Data error related exception
+
+class ExampleTooManyRowsError(core_ex.DataLineError):
+    '''
+    Module exception rasied while line-by-line processing the uploaded
+    data.
+
+    lineno The line number
+    e      The error message
+    descr  More description of the error
+    detail Extra HTML describing the error
+    data   The uploaded data
+    '''
+    def __init__(self, lineno, e, descr='', detail='', data=''):
+        if descr is None:
+            descr = 'Too many rows of uploaded data'
+        super().__init__(e, lineno, descr, detail, data)