forked from rDrama/rDrama
handle error
parent
47f099bf36
commit
f97552b076
|
@ -7,6 +7,7 @@ from collections import Counter
|
|||
import gevent
|
||||
import qrcode
|
||||
from sqlalchemy.orm import aliased, load_only
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
from files.classes import *
|
||||
from files.classes.leaderboard import Leaderboard
|
||||
|
@ -34,7 +35,13 @@ def _add_profile_view(vid, uid):
|
|||
else: view = ViewerRelationship(viewer_id=vid, user_id=uid)
|
||||
db.add(view)
|
||||
|
||||
db.commit()
|
||||
try:
|
||||
db.commit()
|
||||
except IntegrityError as e:
|
||||
db.rollback()
|
||||
if not str(e).startswith('(psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "'):
|
||||
print(STARS + e + STARS, flush=True)
|
||||
|
||||
db.close()
|
||||
stdout.flush()
|
||||
|
||||
|
|
Loading…
Reference in New Issue