Better error checking for document post