If a record already exists, then inserting it will cause a 422 error. However, I’m confused on how to handle this error as it emits an “UnexpectedStatusCodeError”
In this Python code, how can I specifically catch record already exists errors? I tried checking the docs, but couldn’t find how to catch this one as I wish to not raise an exception when it occurs
try:
tenant_collection = get_tenant_collection(tenant_name)
uniqueid = tenant_collection.data.insert(
vector=record.vector,
properties=record.properties,
uuid=record.uniqueid
)
return uniqueid
except:
# if already exists, wil throw 422 error
print('Error in insert record')
traceback.print_exc()
raise Exception("Failed to insert record")