cat-file: refactor error handling of batch_objects