]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix converting Guzzle error codes in s2s storage
authorVincent Petry <pvince81@owncloud.com>
Fri, 10 Apr 2015 10:12:05 +0000 (12:12 +0200)
committerVincent Petry <pvince81@owncloud.com>
Fri, 10 Apr 2015 10:12:05 +0000 (12:12 +0200)
apps/files_sharing/lib/external/storage.php

index 1dfef21ca753d777eef993a0f10e29f61d9dde4e..7c1dc5aeaf5aa8b8a02ae4d4c8eb65f234f8c186 100644 (file)
@@ -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);