Skip to content

Commit 2d4218f

Browse files
committed
fix(ocm-discovery): Throw exception
If we still have an exception at the last iteration of the loop we throw it. Signed-off-by: Micke Nordin <[email protected]>
1 parent b0a33a0 commit 2d4218f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/private/OCM/OCMDiscoveryService.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ public function discover(string $remote, bool $skipCache = false): ICapabilityAw
108108
$remote . '/ocm-provider',
109109
];
110110

111+
111112
foreach ($urls as $url) {
113+
$exception = null;
112114
$body = null;
113115
$status = null;
114116
try {
@@ -127,9 +129,14 @@ public function discover(string $remote, bool $skipCache = false): ICapabilityAw
127129
'exception' => $e,
128130
'remote' => $remote
129131
]);
132+
// We want to throw only the last exception
133+
$exception = $e;
130134
continue;
131135
}
132136
}
137+
if ($exception) {
138+
throw $exception;
139+
}
133140

134141

135142
throw new OCMProviderException('invalid remote ocm endpoint');

0 commit comments

Comments
 (0)