summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-03-20 10:02:05 +0100
committerJoas Schilling <coding@schilljs.com>2017-03-20 10:33:16 +0100
commit591e75df5c3acf51e6968f20b1856481ee56f4de (patch)
treec0f3c7e9d01bb8a00024361541e152cef143f185
parentc4b6ff0bab812ebda50406d630b171604fbaac72 (diff)
downloadnextcloud-server-591e75df5c3acf51e6968f20b1856481ee56f4de.tar.gz
nextcloud-server-591e75df5c3acf51e6968f20b1856481ee56f4de.zip
Don't use a generic exception
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/private/App/AppManager.php9
-rw-r--r--lib/public/App/IAppManager.php1
-rw-r--r--tests/lib/App/ManagerTest.php7
3 files changed, 9 insertions, 8 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index 6c1f5ba6940..42777266249 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -32,7 +32,6 @@
namespace OC\App;
use OCP\App\AppPathNotFoundException;
-use OC_App;
use OCP\App\IAppManager;
use OCP\App\ManagerEvent;
use OCP\IAppConfig;
@@ -211,12 +210,12 @@ class AppManager implements IAppManager {
* Enable an app for every user
*
* @param string $appId
- * @throws \Exception
+ * @throws AppPathNotFoundException
*/
public function enableApp($appId) {
- if(OC_App::getAppPath($appId) === false) {
- throw new \Exception("$appId can't be enabled since it is not installed.");
- }
+ // Check if app exists
+ $this->getAppPath($appId);
+
$this->installedAppsCache[$appId] = 'yes';
$this->appConfig->setValue($appId, 'enabled', 'yes');
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php
index 72c99777124..107297bc890 100644
--- a/lib/public/App/IAppManager.php
+++ b/lib/public/App/IAppManager.php
@@ -57,6 +57,7 @@ interface IAppManager {
* Enable an app for every user
*
* @param string $appId
+ * @throws AppPathNotFoundException
* @since 8.0.0
*/
public function enableApp($appId);
diff --git a/tests/lib/App/ManagerTest.php b/tests/lib/App/ManagerTest.php
index 8b23168938c..59ef9a36bf2 100644
--- a/tests/lib/App/ManagerTest.php
+++ b/tests/lib/App/ManagerTest.php
@@ -134,10 +134,11 @@ class ManagerTest extends TestCase {
try {
$this->manager->enableApp('some_random_name_which_i_hope_is_not_an_app');
$this->assertFalse(true, 'If this line is reached the expected exception is not thrown.');
- } catch (\Exception $e) {
- // excpetion is expected
- $this->assertEquals("some_random_name_which_i_hope_is_not_an_app can't be enabled since it is not installed.", $e->getMessage());
+ } catch (AppPathNotFoundException $e) {
+ // Exception is expected
+ $this->assertEquals('Could not find path for some_random_name_which_i_hope_is_not_an_app', $e->getMessage());
}
+
$this->assertEquals('no', $this->appConfig->getValue(
'some_random_name_which_i_hope_is_not_an_app', 'enabled', 'no'
));