When inserting documents, just try to insert and catch the error.