From 4ead2bc8610d11802c8814976bd80c544459235e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jes=C3=BAs=20Macias?= Date: Thu, 26 Nov 2015 08:26:07 +0100 Subject: [PATCH] Fix code from PR comments --- .../controller/storagescontroller.php | 22 +------------------ lib/public/files/extstorageauthexception.php | 4 ++-- .../files/extstoragebadconfigexception.php | 4 ++-- .../files/extstorageconnectionexception.php | 4 ++-- .../files/extstoragetimeoutexception.php | 4 ++-- .../files/storagenotavailableexception.php | 5 +++++ 6 files changed, 14 insertions(+), 29 deletions(-) diff --git a/apps/files_external/controller/storagescontroller.php b/apps/files_external/controller/storagescontroller.php index 3f781ef655d..76096f76656 100644 --- a/apps/files_external/controller/storagescontroller.php +++ b/apps/files_external/controller/storagescontroller.php @@ -241,29 +241,9 @@ abstract class StoragesController extends Controller { \OC_Mount_Config::STATUS_INDETERMINATE, $this->l10n->t('Insufficient data: %s', [$e->getMessage()]) ); - } catch (ExtStorageBadConfigException $e) { - $storage->setStatus( - $e->getCode(), - $this->l10n->t('%s', [$e->getMessage()]) - ); - } catch (ExtStorageAuthException $e) { - $storage->setStatus( - $e->getCode(), - $this->l10n->t('%s', [$e->getMessage()]) - ); - } catch (ExtStorageTimeoutException $e) { - $storage->setStatus( - $e->getCode(), - $this->l10n->t('%s', [$e->getMessage()]) - ); - } catch (ExtStorageConnectionException $e) { - $storage->setStatus( - $e->getCode(), - $this->l10n->t('%s', [$e->getMessage()]) - ); } catch (StorageNotAvailableException $e) { $storage->setStatus( - \OC_Mount_Config::STATUS_ERROR, + $e->getCode(), $this->l10n->t('%s', [$e->getMessage()]) ); } catch (\Exception $e) { diff --git a/lib/public/files/extstorageauthexception.php b/lib/public/files/extstorageauthexception.php index 4f070b6c0ed..7e7e6f5caa6 100644 --- a/lib/public/files/extstorageauthexception.php +++ b/lib/public/files/extstorageauthexception.php @@ -37,8 +37,8 @@ class ExtStorageAuthException extends StorageNotAvailableException { * @param \Exception $previous * @since 9.0.0 */ - public function __construct($message = '', $code, \Exception $previous = null) { + public function __construct($message = '', \Exception $previous = null) { $l = \OC::$server->getL10N('core'); - parent::__construct($message, $l->t('External storage unauthorized'), 3, $previous); + parent::__construct($l->t('External storage unauthorized. %s', $message), self::STATUS_UNAUTHORIZED, $previous); } } diff --git a/lib/public/files/extstoragebadconfigexception.php b/lib/public/files/extstoragebadconfigexception.php index 869c2d1d139..beb7ff32c81 100644 --- a/lib/public/files/extstoragebadconfigexception.php +++ b/lib/public/files/extstoragebadconfigexception.php @@ -37,9 +37,9 @@ class ExtStorageBadConfigException extends StorageNotAvailableException { * @param \Exception $previous * @since 9.0.0 */ - public function __construct($message = '', $code, \Exception $previous = null) { + public function __construct($message = '', \Exception $previous = null) { $l = \OC::$server->getL10N('core'); - parent::__construct($message, $l->t('External storage incomplete configuration'), 2, $previous); + parent::__construct($l->t('External storage incomplete configuration. %s', $message), self::STATUS_INCOMPLETE_CONF, $previous); } } diff --git a/lib/public/files/extstorageconnectionexception.php b/lib/public/files/extstorageconnectionexception.php index 472d5cd6c52..96d2551ddad 100644 --- a/lib/public/files/extstorageconnectionexception.php +++ b/lib/public/files/extstorageconnectionexception.php @@ -37,8 +37,8 @@ class ExtStorageConnectionException extends StorageNotAvailableException { * @param \Exception $previous * @since 9.0.0 */ - public function __construct($message = '', $code, \Exception $previous = null) { + public function __construct($message = '', \Exception $previous = null) { $l = \OC::$server->getL10N('core'); - parent::__construct($message, $l->t('External storage connection error'), 5, $previous); + parent::__construct($l->t('External storage connection error. %s', $message), self::STATUS_NETWORK_ERROR, $previous); } } diff --git a/lib/public/files/extstoragetimeoutexception.php b/lib/public/files/extstoragetimeoutexception.php index 99932776a80..208f7521432 100644 --- a/lib/public/files/extstoragetimeoutexception.php +++ b/lib/public/files/extstoragetimeoutexception.php @@ -37,8 +37,8 @@ class ExtStorageTimeoutException extends StorageNotAvailableException { * @param \Exception $previous * @since 9.0.0 */ - public function __construct($message = '', $code, \Exception $previous = null) { + public function __construct($message = '', \Exception $previous = null) { $l = \OC::$server->getL10N('core'); - parent::__construct($message, $l->t('External storage connection timeout'), 4, $previous); + parent::__construct($l->t('External storage connection timeout. %s', $message), self::STATUS_TIMEOUT, $previous); } } diff --git a/lib/public/files/storagenotavailableexception.php b/lib/public/files/storagenotavailableexception.php index a6665b38ce1..fe270e76b4e 100644 --- a/lib/public/files/storagenotavailableexception.php +++ b/lib/public/files/storagenotavailableexception.php @@ -37,6 +37,11 @@ use OC\HintException; */ class StorageNotAvailableException extends HintException { + const STATUS_INCOMPLETE_CONF = 3; + const STATUS_UNAUTHORIZED = 4; + const STATUS_TIMEOUT = 5; + const STATUS_NETWORK_ERROR = 6; + /** * StorageNotAvailableException constructor. * -- 2.39.5