From 44e002b6fafe494c8adb370e5f9e80a5bb6777ae Mon Sep 17 00:00:00 2001 From: Dave Brondsema Date: Thu, 17 Mar 2016 10:25:35 -0400 Subject: [PATCH] Better error handling, particularly for unicode issues `logging.exception` already includes the error object information, so don't need to pass it in. And passing it in can cause encoding problems http://bugs.python.org/issue17155 For others, show what operation failed, and re-raise the exception. --- oplogreplay/oplogwatcher.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/oplogreplay/oplogwatcher.py b/oplogreplay/oplogwatcher.py index 133c644..06350e8 100644 --- a/oplogreplay/oplogwatcher.py +++ b/oplogreplay/oplogwatcher.py @@ -72,8 +72,11 @@ def start(self): logging.warning(e) time.sleep(self.poll_time) except OperationFailure, e: - logging.exception(e) + logging.exception("Error") time.sleep(self.poll_time) + except Exception, e: + logging.error("Error handling %r" % op) + raise def stop(self): self.running = False