From e12a4899cfdfe8c1ee7527aad736f9af148a5057 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Wed, 28 Apr 2021 18:54:25 -0500 Subject: [PATCH] Name exception SetupError instead of Error --- src/pgwui_core/core.py | 18 ++++++++++-------- src/pgwui_core/exceptions.py | 28 ++++++++++++++-------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/pgwui_core/core.py b/src/pgwui_core/core.py index a9ff964..31058b4 100644 --- a/src/pgwui_core/core.py +++ b/src/pgwui_core/core.py @@ -1493,7 +1493,7 @@ class DBConnector(object): Returns: (errors, response) - errors List of core_ex.Error instances + errors List of core_ex.SetupError instances response Dict pyramid will use to render the resulting form. The dict returned by func(conn) plus reserved keys. Reserved keys: @@ -1579,7 +1579,7 @@ class DBConnector(object): Returns: (errors, response) - errors List of core_ex.Error instantiations + errors List of core_ex.PGWUIError instantiations response Dict containing connection result info Side effects: @@ -1630,10 +1630,11 @@ class NoTransactionEngine(DBConnector): a transaction. func(conn) Call this function with the connection. - func(conn) must return a list of core_ex.Error instances + func(conn) must return a list of core_ex.PGWUIError + instances Returns: - errors List of core_ex.Error instances + errors List of core_ex.PGWUIError instances Side effects: Calls func(conn) ''' @@ -1703,10 +1704,11 @@ class UnsafeUploadEngine(DBConnector): Call a database modification function with a connection. func(conn) Call this function with the connection. - func(conn) must return a list of core_ex.Error instances + func(conn) must return a list of core_ex.PGWUIError + instances Returns: - errors List of core_ex.Error instances + errors List of core_ex.PGWUIError instances Side effects: Calls func(conn) ''' @@ -1844,12 +1846,12 @@ class UploadEngine(UnsafeUploadEngine): func(conn) Call this function with the connection. f(conn) must return a (errors, dict) tuple result, - errors list of core_ex.Error instances + errors list of core_ex.PWGUIError instances dict other results Returns: (errors, response) - errors List of core_ex.Error instances + errors List of core_ex.PGWUIError instances response Dict pyramid will use to render the resulting form. The dict returned by func(conn) plus reserved keys. Reserved keys: diff --git a/src/pgwui_core/exceptions.py b/src/pgwui_core/exceptions.py index da44643..3b71ed8 100644 --- a/src/pgwui_core/exceptions.py +++ b/src/pgwui_core/exceptions.py @@ -89,7 +89,7 @@ class UploadError(PGWUIError): return self -class Error(UploadError): +class SetupError(UploadError): ''' Module exceptions raised while setting up to read data lines are derived from this class. @@ -99,75 +99,75 @@ class Error(UploadError): detail Extra HTML describing the error ''' def __init__(self, e, descr='', detail=''): - super(Error, self).__init__(e=e, descr=descr, detail=detail) + super(SetupError, self).__init__(e=e, descr=descr, detail=detail) -class NoFileError(Error): +class NoFileError(SetupError): '''No file uploaded''' def __init__(self, e, descr='', detail=''): super(NoFileError, self).__init__(e, descr, detail) -class NoDBError(Error): +class NoDBError(SetupError): '''No database name given''' def __init__(self, e, descr='', detail=''): super(NoDBError, self).__init__(e, descr, detail) -class NoUserError(Error): +class NoUserError(SetupError): '''No user name supplied''' def __init__(self, e, descr='', detail=''): super(NoUserError, self).__init__(e, descr, detail) -class AuthFailError(Error): +class AuthFailError(SetupError): '''Unable to connect to the db''' def __init__(self, e, descr='', detail=''): super(AuthFailError, self).__init__(e, descr, detail) -class DryRunError(Error): +class DryRunError(SetupError): '''Rollback due to dry_run config option''' def __init__(self, e, descr='', detail=''): super(DryRunError, self).__init__(e, descr, detail) -class CSRFError(Error): +class CSRFError(SetupError): '''Invalid CSRF token''' def __init__(self, e, descr='', detail=''): super(CSRFError, self).__init__(e, descr, detail) -class NoHeadersError(Error): +class NoHeadersError(SetupError): '''No column headings found''' def __init__(self, e, descr='', detail=''): super(NoHeadersError, self).__init__(e, descr, detail) -class NoDataError(Error): +class NoDataError(SetupError): '''No data uploaded''' def __init__(self, e, descr='', detail=''): super(NoDataError, self).__init__(e, descr, detail) -class CantDecodeError(Error): +class CantDecodeError(SetupError): '''Can't decode file data into unicode''' def __init__(self, e, descr='', detail=''): super().__init__(e, descr, detail) -class DuplicateUploadError(Error): +class DuplicateUploadError(SetupError): '''The same filename updated twice into the same db''' def __init__(self, e, descr='', detail=''): super(DuplicateUploadError, self).__init__(e, descr, detail) -class DataInconsistencyError(Error): +class DataInconsistencyError(SetupError): def __init__(self, e, descr='', detail=''): super(DataInconsistencyError, self).__init__(e, descr, detail) -class DBError(Error): +class DBError(SetupError): '''psycopg2 raised an error''' def __init__(self, pgexc, e='process your request'): ''' -- 2.34.1