diff --git a/etiquette/constants.py b/etiquette/constants.py index b8893e6..0bf9bb9 100644 --- a/etiquette/constants.py +++ b/etiquette/constants.py @@ -110,11 +110,6 @@ SQL_USER = _sql_dictify(SQL_USER_COLUMNS) # Errors and warnings -ERROR_DATABASE_OUTOFDATE = ''' -Database is out-of-date. {current} should be {new}. -Please use utilities\\etiquette_upgrader.py -'''.strip() - WARNING_MINMAX_INVALID = 'Field "{field}": "{value}" is not a valid request. Ignored.' WARNING_ORDERBY_INVALID = 'Invalid orderby request "{request}". Ignored.' WARNING_ORDERBY_BADCOL = '"{column}" is not a sorting option. Ignored.' diff --git a/etiquette/exceptions.py b/etiquette/exceptions.py index 4ffea87..d247144 100644 --- a/etiquette/exceptions.py +++ b/etiquette/exceptions.py @@ -124,6 +124,16 @@ class WrongLogin(EtiquetteException): # GENERAL ERRORS +OUTOFDATE = ''' +Database is out of date. {current} should be {new}. +Please use utilities\\etiquette_upgrader.py +'''.strip() +class DatabaseOutOfDate(EtiquetteException): + ''' + Raised by PhotoDB __init__ if the user's database is behind. + ''' + error_message = OUTOFDATE + class FeatureDisabled(EtiquetteException): ''' For when features of the system have been disabled by the configuration. diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 0524a2a..398d8f9 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -1113,9 +1113,7 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs self.cur.execute('PRAGMA user_version') existing_version = self.cur.fetchone()[0] if existing_version != DATABASE_VERSION: - message = constants.ERROR_DATABASE_OUTOFDATE - message = message.format(current=existing_version, new=DATABASE_VERSION) - raise SystemExit(message) + raise exceptions.DatabaseOutOfDate(current=existing_version, new=DATABASE_VERSION) statements = DB_INIT.split(';') for statement in statements: