add rudimentary error handling to document insert