Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix with_traceback calls #598

Merged
merged 3 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions knowledge_repo/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ def wrapped(*args, **kwargs):
db_session.rollback()
db_session.add(ErrorLog.from_exception(e))
db_session.commit()
tb = sys.exc_info()[2]
raise e.with_traceback(tb=sys.exc_info()[2])
raise e.with_traceback(sys.exc_info()[2])
return wrapped


Expand Down Expand Up @@ -190,8 +189,7 @@ def __call__(self, *args, **kwargs):
errorlog = ErrorLog.from_exception(e)
db_session.add(errorlog)
db_session.commit()
tb = sys.exc_info()[2]
raise e.with_traceback(tb=sys.exc_info()[2])
raise e.with_traceback(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: 2 additions & 4 deletions knowledge_repo/utils/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def encode(data, encoding='utf-8'):
data = data.encode(encoding)
except Exception as e:
if os.environ.get('DEBUG'):
tb = sys.exc_info()[2]
raise e.with_traceback(tb=sys.exc_info()[2])
raise e.with_traceback(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 @@ -36,8 +35,7 @@ def decode(data, encoding='utf-8'):
data = data.decode(encoding)
except Exception as e:
if os.environ.get('DEBUG'):
tb = sys.exc_info()[2]
raise e.with_traceback(tb=sys.exc_info()[2])
raise e.with_traceback(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