def METHOD_NAME(self, query):
    try:
        try:
            return query.METHOD_NAME(self.conn)
        except pymongo.errors.AutoReconnect:
            logger.warning('Lost connection to the database, '
                           'retrying query.')
            return query.METHOD_NAME(self.conn)
    except pymongo.errors.AutoReconnect as exc:
        raise ConnectionError from exc
    except pymongo.errors.DuplicateKeyError as exc:
        raise DuplicateKeyError from exc
    except pymongo.errors.OperationFailure as exc:
        print(f'DETAILS: {exc.details}')
        raise OperationError from exc