From bafcf6bd2309e4a9c3a041687e81f88a347b82b7 Mon Sep 17 00:00:00 2001 From: Will Starms Date: Tue, 16 Oct 2018 13:55:26 -0500 Subject: [PATCH] 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. --- jupyterhub/apihandlers/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jupyterhub/apihandlers/base.py b/jupyterhub/apihandlers/base.py index 8bc72184..3568d6ae 100644 --- a/jupyterhub/apihandlers/base.py +++ b/jupyterhub/apihandlers/base.py @@ -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')