Add exceptions.DatabaseOutOfDate instead of just using an error string.

And don't raise SystemExit. Not sure what I was thinking.
master
voussoir 2017-11-16 16:33:40 -08:00
parent 009c0dc678
commit 8f000543ea
3 changed files with 11 additions and 8 deletions

View File

@ -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.'

View File

@ -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.

View File

@ -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: