]> source.dussan.org Git - nextcloud-server.git/commitdiff
Convert Dropbox Forbidden exception to StorageNotAvailableException
authorVincent Petry <pvince81@owncloud.com>
Tue, 14 Jun 2016 15:38:32 +0000 (17:38 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 14 Jun 2016 15:38:32 +0000 (17:38 +0200)
apps/files_external/lib/Lib/Storage/Dropbox.php

index f15cbba046940ea308ab09cf58ef8fe070f321f7..f0f62f9f35a6fe6034f671fb5459c997f653502b 100644 (file)
@@ -32,6 +32,7 @@ namespace OCA\Files_External\Lib\Storage;
 use GuzzleHttp\Exception\RequestException;
 use Icewind\Streams\IteratorDirectory;
 use Icewind\Streams\RetryWrapper;
+use OCP\Files\StorageNotAvailableException;
 
 require_once __DIR__ . '/../../../3rdparty/Dropbox/autoload.php';
 
@@ -94,6 +95,8 @@ class Dropbox extends \OC\Files\Storage\Common {
                        if ($list) {
                                try {
                                        $response = $this->dropbox->getMetaData($path);
+                               } catch (\Dropbox_Exception_Forbidden $e) {
+                                       throw new StorageNotAvailableException('Dropbox API rate limit exceeded', StorageNotAvailableException::STATUS_ERROR, $e);
                                } catch (\Exception $exception) {
                                        \OCP\Util::writeLog('files_external', $exception->getMessage(), \OCP\Util::ERROR);
                                        return false;
@@ -127,6 +130,8 @@ class Dropbox extends \OC\Files\Storage\Common {
                                                return $response;
                                        }
                                        return null;
+                               } catch (\Dropbox_Exception_Forbidden $e) {
+                                       throw new StorageNotAvailableException('Dropbox API rate limit exceeded', StorageNotAvailableException::STATUS_ERROR, $e);
                                } catch (\Exception $exception) {
                                        if ($exception instanceof \Dropbox_Exception_NotFound) {
                                                // don't log, might be a file_exist check