Skip to content

Commit f3b1864

Browse files
committed
improve federation error messages
1 parent e4436e4 commit f3b1864

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

apps/federation/lib/Controller/SettingsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ protected function checkServer($url) {
113113
}
114114

115115
if ($this->trustedServers->isOwnCloudServer($url) === false) {
116-
$message = 'No server to federate found';
117-
$hint = $this->l->t('No server to federate found');
116+
$message = 'No server to federate with found';
117+
$hint = $this->l->t('No server to federate with found');
118118
throw new HintException($message, $hint);
119119
}
120120

apps/federation/lib/DbHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function addServer($url) {
8989
if ($result) {
9090
return (int)$this->connection->lastInsertId('*PREFIX*'.$this->dbTable);
9191
} else {
92-
$message = 'Internal failure, Could not add ownCloud as trusted server: ' . $url;
92+
$message = 'Internal failure, Could not add server: ' . $url;
9393
$message_t = $this->IL10N->t('Could not add server');
9494
throw new HintException($message, $message_t);
9595
}

apps/federation/lib/TrustedServers.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,20 @@ public function getServerStatus($url) {
219219
public function isOwnCloudServer($url) {
220220
$isValidOwnCloud = false;
221221
$client = $this->httpClientService->newClient();
222-
$result = $client->get(
223-
$url . '/status.php',
224-
[
225-
'timeout' => 3,
226-
'connect_timeout' => 3,
227-
]
228-
);
229-
if ($result->getStatusCode() === Http::STATUS_OK) {
230-
$isValidOwnCloud = $this->checkOwnCloudVersion($result->getBody());
222+
try {
223+
$result = $client->get(
224+
$url . '/status.php',
225+
[
226+
'timeout' => 3,
227+
'connect_timeout' => 3,
228+
]
229+
);
230+
if ($result->getStatusCode() === Http::STATUS_OK) {
231+
$isValidOwnCloud = $this->checkOwnCloudVersion($result->getBody());
232+
233+
}
234+
} catch (\Exception $e) {
235+
return false;
231236
}
232237

233238
return $isValidOwnCloud;

apps/federation/tests/TrustedServersTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ public function dataTestIsOwnCloudServer() {
309309
}
310310

311311
/**
312-
* @expectedException \Exception
313312
* @expectedExceptionMessage simulated exception
314313
*/
315314
public function testIsOwnCloudServerFail() {
@@ -323,7 +322,7 @@ public function testIsOwnCloudServerFail() {
323322
throw new \Exception('simulated exception');
324323
});
325324

326-
$this->trustedServers->isOwnCloudServer($server);
325+
$this->assertFalse($this->trustedServers->isOwnCloudServer($server));
327326
}
328327

329328
/**

0 commit comments

Comments
 (0)