]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add different storage status codes managed by StoragedNotAvailableException
authorJesús Macias <jmacias@solidgear.es>
Wed, 25 Nov 2015 10:58:54 +0000 (11:58 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 3 Dec 2015 08:57:54 +0000 (09:57 +0100)
apps/files_external/controller/storagescontroller.php
apps/files_external/lib/config.php

index c66bd902d8db115705c40fad2fa95e1b6a284d6d..7efe76114072567fa88bae3e114dc5a412204f9d 100644 (file)
@@ -242,10 +242,44 @@ abstract class StoragesController extends Controller {
                                $this->l10n->t('Insufficient data: %s', [$e->getMessage()])
                        );
                } catch (StorageNotAvailableException $e) {
-                       $storage->setStatus(
-                               \OC_Mount_Config::STATUS_ERROR,
-                               $e->getMessage()
-                       );
+                       switch ($e->getCode()) {
+                               case 1:
+                                       $storage->setStatus(
+                                               \OC_Mount_Config::STATUS_ERROR,
+                                               $this->l10n->t('%s', [$e->getMessage()])
+                                       );
+                                       break;
+                               case 3:
+                                       $storage->setStatus(
+                                               \OC_Mount_Config::STATUS_INCOMPLETE_CONF,
+                                               $this->l10n->t('Incomplete configuration. %s', [$e->getMessage()])
+                                       );
+                                       break;
+                               case 4:
+                                       $storage->setStatus(
+                                               \OC_Mount_Config::STATUS_UNAUTHORIZED,
+                                               $this->l10n->t('Unauthorized. %s', [$e->getMessage()])
+                                               $e->getMessage()
+                                       );
+                                       break;
+                               case 5:
+                                       $storage->setStatus(
+                                               \OC_Mount_Config::STATUS_TIMEOUT,
+                                               $this->l10n->t('Timeout. %s', [$e->getMessage()])
+                                       );
+                                       break;
+                               case 6:
+                                       $storage->setStatus(
+                                               \OC_Mount_Config::STATUS_NETWORK_ERROR,
+                                               $this->l10n->t('Network error. %s', [$e->getMessage()])
+                                       );
+                                       break;
+                               default:
+                                       $storage->setStatus(
+                                               \OC_Mount_Config::STATUS_ERROR,
+                                               $this->l10n->t('%s', [$e->getMessage()])
+                                       );
+                       }
                } catch (\Exception $e) {
                        // FIXME: convert storage exceptions to StorageNotAvailableException
                        $storage->setStatus(
index 1e96fac8145b8e5cae78236a96a51664ade698a2..bf507233035e91ce8b43c5c4c996ba755e4c9552 100644 (file)
@@ -52,6 +52,10 @@ class OC_Mount_Config {
        const STATUS_SUCCESS = 0;
        const STATUS_ERROR = 1;
        const STATUS_INDETERMINATE = 2;
+       const STATUS_INCOMPLETE_CONF = 3;
+       const STATUS_UNAUTHORIZED = 4;
+       const STATUS_TIMEOUT = 5;
+       const STATUS_NETWORK_ERROR = 6;
 
        // whether to skip backend test (for unit tests, as this static class is not mockable)
        public static $skipTest = false;