2626namespace OC \Files \ObjectStore ;
2727
2828use Guzzle \Http \Exception \ClientErrorResponseException ;
29+ use Guzzle \Http \Exception \CurlException ;
2930use Icewind \Streams \RetryWrapper ;
3031use OCP \Files \ObjectStore \IObjectStore ;
3132use OCP \Files \StorageAuthException ;
@@ -87,6 +88,9 @@ public function __construct($params) {
8788 $ this ->params = $ params ;
8889 }
8990
91+ /**
92+ * @suppress PhanNonClassMethodCall
93+ */
9094 protected function init () {
9195 if ($ this ->container ) {
9296 return ;
@@ -117,6 +121,10 @@ protected function init() {
117121 /** @var Catalog $catalog */
118122 $ catalog = $ this ->client ->getCatalog ();
119123
124+ if (count ($ catalog ->getItems ()) === 0 ) {
125+ throw new StorageAuthException ('Keystone did not provide a valid catalog, verify the credentials ' );
126+ }
127+
120128 if (isset ($ this ->params ['serviceName ' ])) {
121129 $ serviceName = $ this ->params ['serviceName ' ];
122130 } else {
@@ -153,6 +161,13 @@ protected function init() {
153161 } else {
154162 throw $ ex ;
155163 }
164+ } catch (CurlException $ e ) {
165+ if ($ e ->getErrorNo () === 7 ) {
166+ $ host = $ e ->getCurlHandle ()->getUrl ()->getHost () . ': ' . $ e ->getCurlHandle ()->getUrl ()->getPort ();
167+ \OC ::$ server ->getLogger ()->error ("Can't connect to object storage server at $ host " );
168+ throw new StorageNotAvailableException ("Can't connect to object storage server at $ host " , StorageNotAvailableException::STATUS_ERROR , $ e );
169+ }
170+ throw $ e ;
156171 }
157172 }
158173
@@ -176,7 +191,7 @@ private function importToken() {
176191 $ itemClass = new \stdClass ();
177192 $ itemClass ->name = $ item ['name ' ];
178193 $ itemClass ->endpoints = array_map (function (array $ endpoint ) {
179- return (object ) $ endpoint ;
194+ return (object )$ endpoint ;
180195 }, $ item ['endpoints ' ]);
181196 $ itemClass ->type = $ item ['type ' ];
182197
0 commit comments