// 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);