From 5626a02d69e26bda25bc14f9e5405dce7f928d17 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 1 Apr 2015 17:12:28 +0200 Subject: [PATCH] throw exception if setup is incomplete --- apps/user_ldap/lib/connection.php | 4 ++- lib/private/hook.php | 3 +++ lib/private/servernotavailableexception.php | 27 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 lib/private/servernotavailableexception.php diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 3869f5da9c..1e18a8d4aa 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -31,6 +31,8 @@ namespace OCA\user_ldap\lib; //magic properties (incomplete) +use OC\ServerNotAvailableException; + /** * responsible for LDAP connections in context with the provided configuration * @@ -168,7 +170,7 @@ class Connection extends LDAPUtility { } if(is_null($this->ldapConnectionRes)) { \OCP\Util::writeLog('user_ldap', 'No LDAP Connection to server ' . $this->connection->ldapHost, \OCP\Util::ERROR); - throw new \Exception('Connection to LDAP server could not be established'); + throw new ServerNotAvailableException('Connection to LDAP server could not be established'); } return $this->ldapConnectionRes; } diff --git a/lib/private/hook.php b/lib/private/hook.php index c4ea1999b0..1e7a084bc3 100644 --- a/lib/private/hook.php +++ b/lib/private/hook.php @@ -114,6 +114,9 @@ class OC_Hook{ OC_Log::write('hook', 'error while running hook (' . $class . '::' . $i["name"] . '): ' . $message, OC_Log::ERROR); + if($e instanceof \OC\ServerNotAvailableException && $signalclass === 'OC_Filesystem' && $signalname === 'setup') { + throw $e; + } } } diff --git a/lib/private/servernotavailableexception.php b/lib/private/servernotavailableexception.php new file mode 100644 index 0000000000..5a57917d23 --- /dev/null +++ b/lib/private/servernotavailableexception.php @@ -0,0 +1,27 @@ + + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC; + + +class ServerNotAvailableException extends \Exception { + +}