From 90f42025acddba70e7f045e069b301013d3d8bbc Mon Sep 17 00:00:00 2001 From: Florian Weber Date: Sat, 21 Jul 2018 10:19:20 +0200 Subject: [PATCH] Fix error handling in PrestissimoFileFetcher (#88) --- src/PrestissimoFileFetcher.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/PrestissimoFileFetcher.php b/src/PrestissimoFileFetcher.php index a1f8e70..fe8f4d3 100644 --- a/src/PrestissimoFileFetcher.php +++ b/src/PrestissimoFileFetcher.php @@ -54,10 +54,11 @@ protected function fetchWithPrestissimo($version, $destination, $override) { } $successCnt = $failureCnt = 0; + $errors = []; $totalCnt = count($requests); if ($totalCnt == 0) { return; - } + } $multi = new CurlMulti(); $multi->setRequests($requests); @@ -67,12 +68,18 @@ protected function fetchWithPrestissimo($version, $destination, $override) { $result = $multi->getFinishedResults(); $successCnt += $result['successCnt']; $failureCnt += $result['failureCnt']; + $errors += $result['errors']; if ($this->progress) { foreach ($result['urls'] as $url) { $this->io->writeError(" - Downloading $successCnt/$totalCnt: $url", TRUE); } } } while ($multi->remain()); + + $urls = array_keys($errors); + if ($urls) { + throw new \Exception('Failed to download ' . implode(", ", $urls)); + } } }