[vcpkg] Improve error message on mistyped package name.

This commit is contained in:
Robert Schumacher 2016-09-29 14:31:28 -07:00
Родитель 8ebee0b23e
Коммит 2d95d71828
2 изменённых файлов: 27 добавлений и 23 удалений

Просмотреть файл

@ -213,35 +213,40 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar
std::vector<std::string> vcpkg::get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db) std::vector<std::string> vcpkg::get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db)
{ {
std::vector<std::unordered_map<std::string, std::string>> pghs; std::vector<std::unordered_map<std::string, std::string>> pghs;
const fs::path packages_dir_control_file_path = paths.package_dir(spec) / "CONTROL";
if (fs::exists(packages_dir_control_file_path))
{ {
try const fs::path packages_dir_control_file_path = paths.package_dir(spec) / "CONTROL";
{
pghs = get_paragraphs(packages_dir_control_file_path);
}
catch (std::runtime_error)
{
// ??
}
Checks::check_throw(pghs.size() == 1, "Invalid control file for package"); auto control_contents_maybe = Files::get_contents(packages_dir_control_file_path);
return BinaryParagraph(pghs[0]).depends; if (auto control_contents = control_contents_maybe.get())
{
try
{
pghs = parse_paragraphs(*control_contents);
}
catch (std::runtime_error)
{
}
Checks::check_exit(pghs.size() == 1, "Invalid control file at %s", packages_dir_control_file_path.string());
return BinaryParagraph(pghs[0]).depends;
}
} }
const fs::path ports_dir_control_file_path = paths.port_dir(spec) / "CONTROL"; const fs::path ports_dir_control_file_path = paths.port_dir(spec) / "CONTROL";
try auto control_contents_maybe = Files::get_contents(ports_dir_control_file_path);
if (auto control_contents = control_contents_maybe.get())
{ {
pghs = get_paragraphs(ports_dir_control_file_path); try
} {
catch (std::runtime_error) pghs = parse_paragraphs(*control_contents);
{ }
// ?? catch (std::runtime_error)
{
}
Checks::check_exit(pghs.size() == 1, "Invalid control file at %s", ports_dir_control_file_path.string());
return SourceParagraph(pghs[0]).depends;
} }
Checks::check_exit(pghs.size() == 1, "Invalid control file for package %s", spec); Checks::exit_with_message("Could not find package named %s", spec);
return SourceParagraph(pghs[0]).depends;
} }
void vcpkg::install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db) void vcpkg::install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db)

Просмотреть файл

@ -34,8 +34,7 @@ namespace vcpkg {namespace Checks
{ {
if (!expression) if (!expression)
{ {
System::println(System::color::error, errorMessage); exit_with_message(errorMessage);
exit(EXIT_FAILURE);
} }
} }
}} }}