1313use Aws \S3 \S3Client ;
1414use GuzzleHttp \Promise \Create ;
1515use GuzzleHttp \Promise \RejectedPromise ;
16+ use OCP \Files \StorageNotAvailableException ;
1617use OCP \ICertificateManager ;
1718use OCP \Server ;
1819use Psr \Log \LoggerInterface ;
@@ -132,7 +133,7 @@ public function getConnection() {
132133 try {
133134 $ logger ->info ('Bucket " ' . $ this ->bucket . '" does not exist - creating it. ' , ['app ' => 'objectstore ' ]);
134135 if (!$ this ->connection ::isBucketDnsCompatible ($ this ->bucket )) {
135- throw new \ Exception ('The bucket will not be created because the name is not dns compatible, please correct it: ' . $ this ->bucket );
136+ throw new StorageNotAvailableException ('The bucket will not be created because the name is not dns compatible, please correct it: ' . $ this ->bucket );
136137 }
137138 $ this ->connection ->createBucket (['Bucket ' => $ this ->bucket ]);
138139 $ this ->testTimeout ();
@@ -142,17 +143,17 @@ public function getConnection() {
142143 'app ' => 'objectstore ' ,
143144 ]);
144145 if ($ e ->getAwsErrorCode () !== 'BucketAlreadyOwnedByYou ' ) {
145- throw new \ Exception ('Creation of bucket " ' . $ this ->bucket . '" failed. ' . $ e ->getMessage ());
146+ throw new StorageNotAvailableException ('Creation of bucket " ' . $ this ->bucket . '" failed. ' . $ e ->getMessage ());
146147 }
147148 }
148149 }
149-
150+
150151 // google cloud's s3 compatibility doesn't like the EncodingType parameter
151152 if (strpos ($ base_url , 'storage.googleapis.com ' )) {
152153 $ this ->connection ->getHandlerList ()->remove ('s3.auto_encode ' );
153154 }
154155 } catch (S3Exception $ e ) {
155- throw new \ Exception ('S3 service is unable to handle request: ' . $ e ->getMessage ());
156+ throw new StorageNotAvailableException ('S3 service is unable to handle request: ' . $ e ->getMessage ());
156157 }
157158
158159 return $ this ->connection ;
0 commit comments