fixed error handling for mongo errors