ajdavis/mongo-python-driver — pull request #6 by FlorianLudwig (2013-01-01 22:33:52+00:00)
Title: Motor

When an error occurs during open_sync() the error is rethrown like this:

Traceback (most recent call last):
File "test.py", line 27, in
connection = motor.MotorConnection().open_sync()
File "mongo-python-driver/motor/__init__.py", line 682, in open_sync
raise outcome['error']
ZeroDivisionError: integer division or modulo by zero

The traceback does not contain any information about the actual call stack at the time of the exception. This patch changes the error handling to save the full traceback object and not just the exception and then print the traceback resulting in an error message like this:

File "motor/__init__.py", line 612, in _connect
self.delegate = self.__delegate_class__(*args, **kwargs)
File "mongo-python-driver/pymongo/connection.py", line 203, in __init__
1/0
ZeroDivisionError: integer division or modulo by zero

This is a slightly changed patch from pull request 2. The usage of sys.exit() was my lazyness and is not expected behavior. Still for easier debugging purposes I believe the information should be printed. Which would be the appropriate way to log this case?