aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorDaniel Shaw <t-dansha@microsoft.com>2017-06-05 15:58:47 -0700
committerDaniel Shaw <t-dansha@microsoft.com>2017-06-06 14:02:59 -0700
commit264cd050e6280e5b87ec055e0a9d8985a7ba30b3 (patch)
treef508fa927970257011747643f893b182691dac1e /toolsrc/src
parent7b4d83c444b0e7fee241ed293614efca17c67201 (diff)
downloadvcpkg-264cd050e6280e5b87ec055e0a9d8985a7ba30b3.tar.gz
vcpkg-264cd050e6280e5b87ec055e0a9d8985a7ba30b3.zip
ExpectedT factory class
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/PackageSpec.cpp10
-rw-r--r--toolsrc/src/PackageSpecParseResult.cpp24
-rw-r--r--toolsrc/src/Paragraphs.cpp23
-rw-r--r--toolsrc/src/SourceParagraph.cpp47
-rw-r--r--toolsrc/src/commands_build.cpp17
-rw-r--r--toolsrc/src/tests_paragraph.cpp66
-rw-r--r--toolsrc/src/vcpkg.cpp4
-rw-r--r--toolsrc/src/vcpkg_Dependencies.cpp10
-rw-r--r--toolsrc/src/vcpkg_Files.cpp6
-rw-r--r--toolsrc/src/vcpkg_Input.cpp4
10 files changed, 124 insertions, 87 deletions
diff --git a/toolsrc/src/PackageSpec.cpp b/toolsrc/src/PackageSpec.cpp
index 69883a030..ab005f255 100644
--- a/toolsrc/src/PackageSpec.cpp
+++ b/toolsrc/src/PackageSpec.cpp
@@ -7,7 +7,8 @@ namespace vcpkg
{
static bool is_valid_package_spec_char(char c) { return (c == '-') || isdigit(c) || (isalpha(c) && islower(c)); }
- Expected<PackageSpec> PackageSpec::from_string(const std::string& spec_as_string, const Triplet& default_triplet)
+ ExpectedT<PackageSpec, PackageSpecParseResult> PackageSpec::from_string(const std::string& spec_as_string,
+ const Triplet& default_triplet)
{
auto pos = spec_as_string.find(':');
if (pos == std::string::npos)
@@ -18,7 +19,7 @@ namespace vcpkg
auto pos2 = spec_as_string.find(':', pos + 1);
if (pos2 != std::string::npos)
{
- return std::error_code(PackageSpecParseResult::TOO_MANY_COLONS);
+ return PackageSpecParseResult::TOO_MANY_COLONS;
}
const std::string name = spec_as_string.substr(0, pos);
@@ -26,11 +27,12 @@ namespace vcpkg
return from_name_and_triplet(name, triplet);
}
- Expected<PackageSpec> PackageSpec::from_name_and_triplet(const std::string& name, const Triplet& triplet)
+ ExpectedT<PackageSpec, PackageSpecParseResult> PackageSpec::from_name_and_triplet(const std::string& name,
+ const Triplet& triplet)
{
if (Util::find_if_not(name, is_valid_package_spec_char) != name.end())
{
- return std::error_code(PackageSpecParseResult::INVALID_CHARACTERS);
+ return PackageSpecParseResult::INVALID_CHARACTERS;
}
PackageSpec p;
diff --git a/toolsrc/src/PackageSpecParseResult.cpp b/toolsrc/src/PackageSpecParseResult.cpp
index 487c3aa1d..838c788ba 100644
--- a/toolsrc/src/PackageSpecParseResult.cpp
+++ b/toolsrc/src/PackageSpecParseResult.cpp
@@ -5,11 +5,9 @@
namespace vcpkg
{
- const char* PackageSpecParseResultCategoryImpl::name() const noexcept { return "PackageSpecParseResult"; }
-
- std::string PackageSpecParseResultCategoryImpl::message(int ev) const noexcept
+ CStringView to_string(PackageSpecParseResult ev) noexcept
{
- switch (static_cast<PackageSpecParseResult>(ev))
+ switch (ev)
{
case PackageSpecParseResult::SUCCESS: return "OK";
case PackageSpecParseResult::TOO_MANY_COLONS: return "Too many colons";
@@ -19,22 +17,4 @@ namespace vcpkg
default: Checks::unreachable(VCPKG_LINE_INFO);
}
}
-
- const std::error_category& package_spec_parse_result_category()
- {
- static PackageSpecParseResultCategoryImpl instance;
- return instance;
- }
-
- std::error_code make_error_code(PackageSpecParseResult e)
- {
- return std::error_code(static_cast<int>(e), package_spec_parse_result_category());
- }
-
- PackageSpecParseResult to_package_spec_parse_result(int i) { return static_cast<PackageSpecParseResult>(i); }
-
- PackageSpecParseResult to_package_spec_parse_result(std::error_code ec)
- {
- return to_package_spec_parse_result(ec.value());
- }
}
diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp
index 70d3db2b3..13103d1f8 100644
--- a/toolsrc/src/Paragraphs.cpp
+++ b/toolsrc/src/Paragraphs.cpp
@@ -168,7 +168,7 @@ namespace vcpkg::Paragraphs
return parse_single_paragraph(*spgh);
}
- return contents.error_code();
+ return contents.error();
}
Expected<std::vector<std::unordered_map<std::string, std::string>>> get_paragraphs(const Files::Filesystem& fs,
@@ -180,7 +180,7 @@ namespace vcpkg::Paragraphs
return parse_paragraphs(*spgh);
}
- return contents.error_code();
+ return contents.error();
}
Expected<std::unordered_map<std::string, std::string>> parse_single_paragraph(const std::string& str)
@@ -201,15 +201,16 @@ namespace vcpkg::Paragraphs
return Parser(str.c_str(), str.c_str() + str.size()).get_paragraphs();
}
- Expected<SourceParagraph> try_load_port(const Files::Filesystem& fs, const fs::path& path)
+ ExpectedT<SourceParagraph, ParseControlErrorInfo> try_load_port(const Files::Filesystem& fs, const fs::path& path)
{
+ ParseControlErrorInfo error_info;
Expected<std::unordered_map<std::string, std::string>> pghs = get_single_paragraph(fs, path / "CONTROL");
if (auto p = pghs.get())
{
- return SourceParagraph(*p);
+ return SourceParagraph::parse_control_file(*p);
}
-
- return pghs.error_code();
+ error_info.error = pghs.error();
+ return error_info;
}
Expected<BinaryParagraph> try_load_cached_package(const VcpkgPaths& paths, const PackageSpec& spec)
@@ -222,20 +223,26 @@ namespace vcpkg::Paragraphs
return BinaryParagraph(*p);
}
- return pghs.error_code();
+ return pghs.error();
}
std::vector<SourceParagraph> load_all_ports(const Files::Filesystem& fs, const fs::path& ports_dir)
{
std::vector<SourceParagraph> output;
+ std::vector<ParseControlErrorInfo> port_errors;
for (auto&& path : fs.get_files_non_recursive(ports_dir))
{
- Expected<SourceParagraph> source_paragraph = try_load_port(fs, path);
+ ExpectedT<SourceParagraph, ParseControlErrorInfo> source_paragraph = try_load_port(fs, path);
if (auto srcpgh = source_paragraph.get())
{
output.emplace_back(std::move(*srcpgh));
}
+ else
+ {
+ port_errors.emplace_back(source_paragraph.error());
+ }
}
+ print_error_message(port_errors);
return output;
}
diff --git a/toolsrc/src/SourceParagraph.cpp b/toolsrc/src/SourceParagraph.cpp
index d140ce72b..9516681c9 100644
--- a/toolsrc/src/SourceParagraph.cpp
+++ b/toolsrc/src/SourceParagraph.cpp
@@ -5,6 +5,8 @@
#include "vcpkg_Checks.h"
#include "vcpkg_Maps.h"
#include "vcpkg_System.h"
+#include "vcpkg_expected.h"
+
#include "vcpkglib_helpers.h"
namespace vcpkg
@@ -37,15 +39,41 @@ namespace vcpkg
SourceParagraph::SourceParagraph() = default;
- SourceParagraph::SourceParagraph(std::unordered_map<std::string, std::string> fields)
+ void print_error_message(const ParseControlErrorInfo& info)
+ {
+ System::println(
+ System::Color::error, "Error: There are invalid fields in the Source Paragraph of %s", info.name);
+ System::println("The following fields were not expected:\n\n %s\n\n", info.remaining_fields_as_string);
+ System::println("This is the list of valid fields (case-sensitive): \n\n %s\n", info.valid_fields_as_string);
+ System::println("Different source may be available for vcpkg. Use .\\bootstrap-vcpkg.bat to update.\n");
+ }
+
+ void print_error_message(std::vector<ParseControlErrorInfo> error_info_list)
+ {
+ for (ParseControlErrorInfo error_info : error_info_list)
+ {
+ System::println(
+ System::Color::error, "Error: There are invalid fields in the Source Paragraph of %s", error_info.name);
+ System::println("The following fields were not expected:\n\n %s\n\n",
+ error_info.remaining_fields_as_string);
+ }
+
+ System::println("This is the list of valid fields (case-sensitive): \n\n %s\n",
+ error_info_list.front().valid_fields_as_string);
+ System::println("Different source may be available for vcpkg. Use .\\bootstrap-vcpkg.bat to update.\n");
+ }
+
+ ExpectedT<SourceParagraph, ParseControlErrorInfo> SourceParagraph::parse_control_file(
+ std::unordered_map<std::string, std::string> fields)
{
- this->name = details::remove_required_field(&fields, SourceParagraphRequiredField::SOURCE);
- this->version = details::remove_required_field(&fields, SourceParagraphRequiredField::VERSION);
- this->description = details::remove_optional_field(&fields, SourceParagraphOptionalField::DESCRIPTION);
- this->maintainer = details::remove_optional_field(&fields, SourceParagraphOptionalField::MAINTAINER);
+ SourceParagraph sparagraph;
+ sparagraph.name = details::remove_required_field(&fields, SourceParagraphRequiredField::SOURCE);
+ sparagraph.version = details::remove_required_field(&fields, SourceParagraphRequiredField::VERSION);
+ sparagraph.description = details::remove_optional_field(&fields, SourceParagraphOptionalField::DESCRIPTION);
+ sparagraph.maintainer = details::remove_optional_field(&fields, SourceParagraphOptionalField::MAINTAINER);
std::string deps = details::remove_optional_field(&fields, SourceParagraphOptionalField::BUILD_DEPENDS);
- this->depends = expand_qualified_dependencies(parse_depends(deps));
+ sparagraph.depends = expand_qualified_dependencies(parse_depends(deps));
if (!fields.empty())
{
@@ -55,12 +83,9 @@ namespace vcpkg
const std::string remaining_fields_as_string = Strings::join("\n ", remaining_fields);
const std::string valid_fields_as_string = Strings::join("\n ", valid_fields);
- System::println(
- System::Color::error, "Error: There are invalid fields in the Source Paragraph of %s", this->name);
- System::println("The following fields were not expected:\n\n %s\n\n", remaining_fields_as_string);
- System::println("This is the list of valid fields (case-sensitive): \n\n %s\n", valid_fields_as_string);
- Checks::exit_fail(VCPKG_LINE_INFO);
+ return ParseControlErrorInfo{sparagraph.name, remaining_fields_as_string, valid_fields_as_string};
}
+ return sparagraph;
}
std::vector<Dependency> vcpkg::expand_qualified_dependencies(const std::vector<std::string>& depends)
diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp
index ec6586fa3..4a0cee021 100644
--- a/toolsrc/src/commands_build.cpp
+++ b/toolsrc/src/commands_build.cpp
@@ -33,13 +33,16 @@ namespace vcpkg::Commands::BuildCommand
Checks::exit_success(VCPKG_LINE_INFO);
}
- const Expected<SourceParagraph> maybe_spgh = Paragraphs::try_load_port(paths.get_filesystem(), port_dir);
- Checks::check_exit(VCPKG_LINE_INFO,
- !maybe_spgh.error_code(),
- "Could not find package %s: %s",
- spec,
- maybe_spgh.error_code().message());
- const SourceParagraph& spgh = *maybe_spgh.get();
+ const ExpectedT<SourceParagraph, ParseControlErrorInfo> maybe_spgh =
+ Paragraphs::try_load_port(paths.get_filesystem(), port_dir);
+ // why do we add a const here
+ if (!maybe_spgh)
+ {
+ print_error_message(maybe_spgh.error());
+ Checks::exit_fail(VCPKG_LINE_INFO);
+ }
+
+ const SourceParagraph& spgh = maybe_spgh.value_or_exit(VCPKG_LINE_INFO);
Checks::check_exit(VCPKG_LINE_INFO,
spec.name() == spgh.name,
"The Name: field inside the CONTROL does not match the port directory: '%s' != '%s'",
diff --git a/toolsrc/src/tests_paragraph.cpp b/toolsrc/src/tests_paragraph.cpp
index b66adc816..1c77b437b 100644
--- a/toolsrc/src/tests_paragraph.cpp
+++ b/toolsrc/src/tests_paragraph.cpp
@@ -25,7 +25,10 @@ namespace UnitTest1
{
TEST_METHOD(SourceParagraph_Construct_Minimum)
{
- vcpkg::SourceParagraph pgh({{"Source", "zlib"}, {"Version", "1.2.8"}});
+ auto m_pgh = vcpkg::SourceParagraph::parse_control_file({{"Source", "zlib"}, {"Version", "1.2.8"}});
+
+ Assert::IsTrue(m_pgh.has_value());
+ auto& pgh = *m_pgh.get();
Assert::AreEqual("zlib", pgh.name.c_str());
Assert::AreEqual("1.2.8", pgh.version.c_str());
@@ -36,11 +39,12 @@ namespace UnitTest1
TEST_METHOD(SourceParagraph_Construct_Maximum)
{
- vcpkg::SourceParagraph pgh({{"Source", "s"},
- {"Version", "v"},
- {"Maintainer", "m"},
- {"Description", "d"},
- {"Build-Depends", "bd"}});
+ auto m_pgh = vcpkg::SourceParagraph::parse_control_file({
+ {"Source", "s"}, {"Version", "v"}, {"Maintainer", "m"}, {"Description", "d"}, {"Build-Depends", "bd"},
+ });
+ Assert::IsTrue(m_pgh.has_value());
+ auto& pgh = *m_pgh.get();
+
Assert::AreEqual("s", pgh.name.c_str());
Assert::AreEqual("v", pgh.version.c_str());
Assert::AreEqual("m", pgh.maintainer.c_str());
@@ -51,7 +55,11 @@ namespace UnitTest1
TEST_METHOD(SourceParagraph_Two_Depends)
{
- vcpkg::SourceParagraph pgh({{"Source", "zlib"}, {"Version", "1.2.8"}, {"Build-Depends", "z, openssl"}});
+ auto m_pgh = vcpkg::SourceParagraph::parse_control_file({
+ {"Source", "zlib"}, {"Version", "1.2.8"}, {"Build-Depends", "z, openssl"},
+ });
+ Assert::IsTrue(m_pgh.has_value());
+ auto& pgh = *m_pgh.get();
Assert::AreEqual(size_t(2), pgh.depends.size());
Assert::AreEqual("z", pgh.depends[0].name.c_str());
@@ -60,8 +68,11 @@ namespace UnitTest1
TEST_METHOD(SourceParagraph_Three_Depends)
{
- vcpkg::SourceParagraph pgh(
- {{"Source", "zlib"}, {"Version", "1.2.8"}, {"Build-Depends", "z, openssl, xyz"}});
+ auto m_pgh = vcpkg::SourceParagraph::parse_control_file({
+ {"Source", "zlib"}, {"Version", "1.2.8"}, {"Build-Depends", "z, openssl, xyz"},
+ });
+ Assert::IsTrue(m_pgh.has_value());
+ auto& pgh = *m_pgh.get();
Assert::AreEqual(size_t(3), pgh.depends.size());
Assert::AreEqual("z", pgh.depends[0].name.c_str());
@@ -71,8 +82,11 @@ namespace UnitTest1
TEST_METHOD(SourceParagraph_Construct_Qualified_Depends)
{
- vcpkg::SourceParagraph pgh(
- {{"Source", "zlib"}, {"Version", "1.2.8"}, {"Build-Depends", "libA [windows], libB [uwp]"}});
+ auto m_pgh = vcpkg::SourceParagraph::parse_control_file({
+ {"Source", "zlib"}, {"Version", "1.2.8"}, {"Build-Depends", "libA [windows], libB [uwp]"},
+ });
+ Assert::IsTrue(m_pgh.has_value());
+ auto& pgh = *m_pgh.get();
Assert::AreEqual("zlib", pgh.name.c_str());
Assert::AreEqual("1.2.8", pgh.version.c_str());
@@ -101,13 +115,15 @@ namespace UnitTest1
TEST_METHOD(BinaryParagraph_Construct_Maximum)
{
- vcpkg::BinaryParagraph pgh({{"Package", "s"},
- {"Version", "v"},
- {"Architecture", "x86-windows"},
- {"Multi-Arch", "same"},
- {"Maintainer", "m"},
- {"Description", "d"},
- {"Depends", "bd"}});
+ vcpkg::BinaryParagraph pgh({
+ {"Package", "s"},
+ {"Version", "v"},
+ {"Architecture", "x86-windows"},
+ {"Multi-Arch", "same"},
+ {"Maintainer", "m"},
+ {"Description", "d"},
+ {"Depends", "bd"},
+ });
Assert::AreEqual("s", pgh.spec.name().c_str());
Assert::AreEqual("v", pgh.version.c_str());
Assert::AreEqual("m", pgh.maintainer.c_str());
@@ -327,28 +343,26 @@ namespace UnitTest1
TEST_METHOD(package_spec_parse)
{
- vcpkg::Expected<vcpkg::PackageSpec> spec =
+ vcpkg::ExpectedT<vcpkg::PackageSpec, vcpkg::PackageSpecParseResult> spec =
vcpkg::PackageSpec::from_string("zlib", vcpkg::Triplet::X86_WINDOWS);
- Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS,
- vcpkg::to_package_spec_parse_result(spec.error_code()));
+ Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, spec.error());
Assert::AreEqual("zlib", spec.get()->name().c_str());
Assert::AreEqual(vcpkg::Triplet::X86_WINDOWS.canonical_name(), spec.get()->triplet().canonical_name());
}
TEST_METHOD(package_spec_parse_with_arch)
{
- vcpkg::Expected<vcpkg::PackageSpec> spec =
+ vcpkg::ExpectedT<vcpkg::PackageSpec, vcpkg::PackageSpecParseResult> spec =
vcpkg::PackageSpec::from_string("zlib:x64-uwp", vcpkg::Triplet::X86_WINDOWS);
- Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS,
- vcpkg::to_package_spec_parse_result(spec.error_code()));
+ Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, spec.error());
Assert::AreEqual("zlib", spec.get()->name().c_str());
Assert::AreEqual(vcpkg::Triplet::X64_UWP.canonical_name(), spec.get()->triplet().canonical_name());
}
TEST_METHOD(package_spec_parse_with_multiple_colon)
{
- auto ec = vcpkg::PackageSpec::from_string("zlib:x86-uwp:", vcpkg::Triplet::X86_WINDOWS).error_code();
- Assert::AreEqual(vcpkg::PackageSpecParseResult::TOO_MANY_COLONS, vcpkg::to_package_spec_parse_result(ec));
+ auto ec = vcpkg::PackageSpec::from_string("zlib:x86-uwp:", vcpkg::Triplet::X86_WINDOWS).error();
+ Assert::AreEqual(vcpkg::PackageSpecParseResult::TOO_MANY_COLONS, ec);
}
TEST_METHOD(utf8_to_utf16)
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index 154aefd0a..738b7b284 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -61,10 +61,10 @@ static void inner(const VcpkgCmdArguments& args)
const Expected<VcpkgPaths> expected_paths = VcpkgPaths::create(vcpkg_root_dir);
Checks::check_exit(VCPKG_LINE_INFO,
- !expected_paths.error_code(),
+ !expected_paths.error(),
"Error: Invalid vcpkg root directory %s: %s",
vcpkg_root_dir.string(),
- expected_paths.error_code().message());
+ expected_paths.error().message());
const VcpkgPaths paths = expected_paths.value_or_exit(VCPKG_LINE_INFO);
int exit_code = _wchdir(paths.root.c_str());
Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Changing the working dir failed");
diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp
index acfb55239..ea5832e46 100644
--- a/toolsrc/src/vcpkg_Dependencies.cpp
+++ b/toolsrc/src/vcpkg_Dependencies.cpp
@@ -174,11 +174,14 @@ namespace vcpkg::Dependencies
if (auto bpgh = maybe_bpgh.get())
return InstallPlanAction{spec, {nullopt, *bpgh, nullopt}, request_type};
- Expected<SourceParagraph> maybe_spgh =
+ ExpectedT<SourceParagraph, ParseControlErrorInfo> maybe_spgh =
Paragraphs::try_load_port(paths.get_filesystem(), paths.port_dir(spec));
if (auto spgh = maybe_spgh.get())
return InstallPlanAction{spec, {nullopt, nullopt, *spgh}, request_type};
+ else
+ print_error_message(maybe_spgh.error());
+
Checks::exit_with_message(VCPKG_LINE_INFO, "Could not find package %s", spec);
}
};
@@ -283,11 +286,14 @@ namespace vcpkg::Dependencies
if (auto bpgh = maybe_bpgh.get())
return ExportPlanAction{spec, {nullopt, *bpgh, nullopt}, request_type};
- Expected<SourceParagraph> maybe_spgh =
+ ExpectedT<SourceParagraph, ParseControlErrorInfo> maybe_spgh =
Paragraphs::try_load_port(paths.get_filesystem(), paths.port_dir(spec));
if (auto spgh = maybe_spgh.get())
return ExportPlanAction{spec, {nullopt, nullopt, *spgh}, request_type};
+ else
+ print_error_message(maybe_spgh.error());
+
Checks::exit_with_message(VCPKG_LINE_INFO, "Could not find package %s", spec);
}
};
diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp
index 17aa2997a..7b12ea699 100644
--- a/toolsrc/src/vcpkg_Files.cpp
+++ b/toolsrc/src/vcpkg_Files.cpp
@@ -15,7 +15,7 @@ namespace vcpkg::Files
std::fstream file_stream(file_path, std::ios_base::in | std::ios_base::binary);
if (file_stream.fail())
{
- return std::errc::no_such_file_or_directory;
+ return std::make_error_code(std::errc::no_such_file_or_directory);
}
file_stream.seekg(0, file_stream.end);
@@ -24,7 +24,7 @@ namespace vcpkg::Files
if (length > SIZE_MAX)
{
- return std::errc::file_too_large;
+ return std::make_error_code(std::errc::file_too_large);
}
std::string output;
@@ -39,7 +39,7 @@ namespace vcpkg::Files
std::fstream file_stream(file_path, std::ios_base::in | std::ios_base::binary);
if (file_stream.fail())
{
- return std::errc::no_such_file_or_directory;
+ return std::make_error_code(std::errc::no_such_file_or_directory);
}
std::vector<std::string> output;
diff --git a/toolsrc/src/vcpkg_Input.cpp b/toolsrc/src/vcpkg_Input.cpp
index 7d8e4767e..df738315b 100644
--- a/toolsrc/src/vcpkg_Input.cpp
+++ b/toolsrc/src/vcpkg_Input.cpp
@@ -12,14 +12,14 @@ namespace vcpkg::Input
CStringView example_text)
{
const std::string as_lowercase = Strings::ascii_to_lowercase(package_spec_as_string);
- Expected<PackageSpec> expected_spec = PackageSpec::from_string(as_lowercase, default_triplet);
+ auto expected_spec = PackageSpec::from_string(as_lowercase, default_triplet);
if (auto spec = expected_spec.get())
{
return *spec;
}
// Intentionally show the lowercased string
- System::println(System::Color::error, "Error: %s: %s", expected_spec.error_code().message(), as_lowercase);
+ System::println(System::Color::error, "Error: %s: %s", vcpkg::to_string(expected_spec.error()), as_lowercase);
System::print(example_text);
Checks::exit_fail(VCPKG_LINE_INFO);
}