Try to create exception str before logging

The str() method of an InterfaceError can raise when trying to iterate over an integer, causing the logger to act up.
This commit is contained in:
Will Starms
2018-10-16 13:55:26 -05:00
parent 2d6e7186aa
commit bafcf6bd23

View File

@@ -103,7 +103,11 @@ class APIHandler(BaseHandler):
status_message = reason
if exception and isinstance(exception, SQLAlchemyError):
self.log.warning("Rolling back session due to database error %s", exception)
try:
exception_str = str(exception)
self.log.warning("Rolling back session due to database error %s", exception_str)
except Exception:
self.log.warning("Rolling back session due to database error %s", type(exception))
self.db.rollback()
self.set_header('Content-Type', 'application/json')