mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Fix converting Guzzle error codes in s2s storage
This commit is contained in:
parent
73afca6207
commit
b51b5b64e6
1 changed files with 13 additions and 10 deletions
23
apps/files_sharing/lib/external/storage.php
vendored
23
apps/files_sharing/lib/external/storage.php
vendored
|
|
@ -248,16 +248,19 @@ class Storage extends DAV implements ISharedStorage {
|
|||
|
||||
// TODO: DI
|
||||
$client = \OC::$server->getHTTPClientService()->newClient();
|
||||
$response = $client->post($url, ['body' => ['password' => $password]]);
|
||||
|
||||
switch ($response->getStatusCode()) {
|
||||
case 401:
|
||||
case 403:
|
||||
throw new ForbiddenException();
|
||||
case 404:
|
||||
throw new NotFoundException();
|
||||
case 500:
|
||||
throw new \Exception();
|
||||
try {
|
||||
$response = $client->post($url, ['body' => ['password' => $password]]);
|
||||
} catch (\GuzzleHttp\Exception\RequestException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 401:
|
||||
case 403:
|
||||
throw new ForbiddenException();
|
||||
case 404:
|
||||
throw new NotFoundException();
|
||||
case 500:
|
||||
throw new \Exception();
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return json_decode($response->getBody(), true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue