Skip to content

Commit

Permalink
Exception Handled. Fixed - BlitzKraft#168
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavithratr1603 committed Jan 17, 2022
1 parent 75b78a4 commit 6524535
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions saythanks/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
from auth0.v2.management import Auth0

from . import myemail
import traceback # Just to show the full traceback
from psycopg2 import errors

InFailedSqlTransaction = errors.lookup('25P02')


# Auth0 API Client
auth0_domain = os.environ['AUTH0_DOMAIN']
Expand Down Expand Up @@ -116,11 +121,12 @@ def does_exist(cls, slug):

@classmethod
def is_email_enabled(cls, slug):
q = 'SELECT email_enabled FROM inboxes where slug = :slug'
r = db.query(q, slug=slug).all()
q = 'SELECT email_enabled FROM inboxes where slug = :slug'
try:
r = db.query(q, slug=slug).all()
return bool(r[0]['email_enabled'])
except:
except InFailedSqlTransaction:
print(traceback.print_exc())
return False

@classmethod
Expand All @@ -135,11 +141,12 @@ def enable_email(cls, slug):

@classmethod
def is_enabled(cls, slug):
q = 'SELECT enabled FROM inboxes where slug = :slug'
r = db.query(q, slug=slug).all()
q = 'SELECT enabled FROM inboxes where slug = :slug'
try:
r = db.query(q, slug=slug).all()
return bool(r[0]['enabled'])
except:
except InFailedSqlTransaction:
print(traceback.print_exc())
return False

@classmethod
Expand Down

0 comments on commit 6524535

Please sign in to comment.