Update _list_packages to handle errors