From d2bab3c370fca9fa5216d97495810faaeeaebc2d Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 24 Mar 2017 10:46:49 -0700 Subject: Rework Paragraph parsing error handling. Add single paragraph functions --- toolsrc/src/commands_cache.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'toolsrc/src/commands_cache.cpp') diff --git a/toolsrc/src/commands_cache.cpp b/toolsrc/src/commands_cache.cpp index 417799abb..6504c8c4d 100644 --- a/toolsrc/src/commands_cache.cpp +++ b/toolsrc/src/commands_cache.cpp @@ -13,22 +13,11 @@ namespace vcpkg::Commands::Cache for (auto it = fs::directory_iterator(paths.packages); it != fs::directory_iterator(); ++it) { const fs::path& path = it->path(); - - try - { - auto file_contents = Files::read_contents(path / "CONTROL"); - if (auto text = file_contents.get()) - { - auto pghs = Paragraphs::parse_paragraphs(*text); - if (pghs.size() != 1) - continue; - - const BinaryParagraph binary_paragraph = BinaryParagraph(pghs[0]); - output.push_back(binary_paragraph); - } - } - catch (std::runtime_error const&) + const expected> pghs = Paragraphs::get_single_paragraph(path / "CONTROL"); + if (auto p = pghs.get()) { + const BinaryParagraph binary_paragraph = BinaryParagraph(*p); + output.push_back(binary_paragraph); } } -- cgit v1.2.3