Exceptions for PyMongo and PySpark