From 3d80ade8d73c56dcd8b7a6d0c88aa965b77a53e6 Mon Sep 17 00:00:00 2001
From: Morris Jobke <hey@morrisjobke.de>
Date: Wed, 11 Apr 2018 00:05:42 +0200
Subject: [PATCH] Log possible exception caused by wrong version number

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
---
 .../App/AppStore/Fetcher/AppFetcher.php       | 25 +++++++++++--------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php
index 89bc7eb2c4f..5203515e09b 100644
--- a/lib/private/App/AppStore/Fetcher/AppFetcher.php
+++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php
@@ -33,6 +33,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\Http\Client\IClientService;
 use OCP\IConfig;
 use OCP\ILogger;
+use OCP\Util;
 
 class AppFetcher extends Fetcher {
 
@@ -87,16 +88,20 @@ class AppFetcher extends Fetcher {
 				if($release['isNightly'] === false
 					&& strpos($release['version'], '-') === false) {
 					// Exclude all versions not compatible with the current version
-					$versionParser = new VersionParser();
-					$version = $versionParser->getVersion($release['rawPlatformVersionSpec']);
-					$ncVersion = $this->getVersion();
-					$min = $version->getMinimumVersion();
-					$max = $version->getMaximumVersion();
-					$minFulfilled = $this->compareVersion->isCompatible($ncVersion, $min, '>=');
-					$maxFulfilled = $max !== '' &&
-						$this->compareVersion->isCompatible($ncVersion, $max, '<=');
-					if ($minFulfilled && $maxFulfilled) {
-						$releases[] = $release;
+					try {
+						$versionParser = new VersionParser();
+						$version = $versionParser->getVersion($release['rawPlatformVersionSpec']);
+						$ncVersion = $this->getVersion();
+						$min = $version->getMinimumVersion();
+						$max = $version->getMaximumVersion();
+						$minFulfilled = $this->compareVersion->isCompatible($ncVersion, $min, '>=');
+						$maxFulfilled = $max !== '' &&
+							$this->compareVersion->isCompatible($ncVersion, $max, '<=');
+						if ($minFulfilled && $maxFulfilled) {
+							$releases[] = $release;
+						}
+					} catch (\InvalidArgumentException $e) {
+						$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => Util::WARN]);
 					}
 				}
 			}
-- 
GitLab