From 264cd050e6280e5b87ec055e0a9d8985a7ba30b3 Mon Sep 17 00:00:00 2001 From: Daniel Shaw Date: Mon, 5 Jun 2017 15:58:47 -0700 Subject: ExpectedT factory class --- toolsrc/src/Paragraphs.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'toolsrc/src/Paragraphs.cpp') 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>> 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> 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 try_load_port(const Files::Filesystem& fs, const fs::path& path) + ExpectedT try_load_port(const Files::Filesystem& fs, const fs::path& path) { + ParseControlErrorInfo error_info; Expected> 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 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 load_all_ports(const Files::Filesystem& fs, const fs::path& ports_dir) { std::vector output; + std::vector port_errors; for (auto&& path : fs.get_files_non_recursive(ports_dir)) { - Expected source_paragraph = try_load_port(fs, path); + ExpectedT 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; } -- cgit v1.2.3