Skip to content

Commit

Permalink
Merge pull request #589 from serenajiang/fix-traceback
Browse files Browse the repository at this point in the history
fix with_traceback calls
  • Loading branch information
john-bodley authored Nov 24, 2020
2 parents d350a5c + 885f8ac commit 316cacd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions knowledge_repo/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ def wrapped(*args, **kwargs):
db_session.rollback()
db_session.add(ErrorLog.from_exception(e))
db_session.commit()
raise e.with_traceback()
tb = sys.exc_info()[2]
raise e.with_traceback(tb=sys.exc_info()[2])
return wrapped


Expand Down Expand Up @@ -189,7 +190,8 @@ def __call__(self, *args, **kwargs):
errorlog = ErrorLog.from_exception(e)
db_session.add(errorlog)
db_session.commit()
raise e.with_traceback()
tb = sys.exc_info()[2]
raise e.with_traceback(tb=sys.exc_info()[2])
finally:
# Extract object id and type after response generated (if requested) to ensure
# most recent data is collected
Expand Down
6 changes: 4 additions & 2 deletions knowledge_repo/utils/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def encode(data, encoding='utf-8'):
data = data.encode(encoding)
except Exception as e:
if os.environ.get('DEBUG'):
raise e.with_traceback()
tb = sys.exc_info()[2]
raise e.with_traceback(tb=sys.exc_info()[2])
logger.warning("An encoding error has occurred... continuing anyway. To capture these errors, rerun the current command prefixed with `DEBUG=1 `.")
data = data.encode(encoding, errors='ignore')
return data
Expand All @@ -35,7 +36,8 @@ def decode(data, encoding='utf-8'):
data = data.decode(encoding)
except Exception as e:
if os.environ.get('DEBUG'):
raise e.with_traceback()
tb = sys.exc_info()[2]
raise e.with_traceback(tb=sys.exc_info()[2])
logger.warning("An decoding error has occurred... continuing anyway. To capture these errors, rerun the current command prefixed with `DEBUG=1 `.")
data = data.decode(encoding, errors='ignore')
return data

0 comments on commit 316cacd

Please sign in to comment.