Don't use a generic exception
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
c4b6ff0bab
commit
591e75df5c
|
@ -32,7 +32,6 @@
|
||||||
namespace OC\App;
|
namespace OC\App;
|
||||||
|
|
||||||
use OCP\App\AppPathNotFoundException;
|
use OCP\App\AppPathNotFoundException;
|
||||||
use OC_App;
|
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\App\ManagerEvent;
|
use OCP\App\ManagerEvent;
|
||||||
use OCP\IAppConfig;
|
use OCP\IAppConfig;
|
||||||
|
@ -211,12 +210,12 @@ class AppManager implements IAppManager {
|
||||||
* Enable an app for every user
|
* Enable an app for every user
|
||||||
*
|
*
|
||||||
* @param string $appId
|
* @param string $appId
|
||||||
* @throws \Exception
|
* @throws AppPathNotFoundException
|
||||||
*/
|
*/
|
||||||
public function enableApp($appId) {
|
public function enableApp($appId) {
|
||||||
if(OC_App::getAppPath($appId) === false) {
|
// Check if app exists
|
||||||
throw new \Exception("$appId can't be enabled since it is not installed.");
|
$this->getAppPath($appId);
|
||||||
}
|
|
||||||
$this->installedAppsCache[$appId] = 'yes';
|
$this->installedAppsCache[$appId] = 'yes';
|
||||||
$this->appConfig->setValue($appId, 'enabled', 'yes');
|
$this->appConfig->setValue($appId, 'enabled', 'yes');
|
||||||
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
|
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
|
||||||
|
|
|
@ -57,6 +57,7 @@ interface IAppManager {
|
||||||
* Enable an app for every user
|
* Enable an app for every user
|
||||||
*
|
*
|
||||||
* @param string $appId
|
* @param string $appId
|
||||||
|
* @throws AppPathNotFoundException
|
||||||
* @since 8.0.0
|
* @since 8.0.0
|
||||||
*/
|
*/
|
||||||
public function enableApp($appId);
|
public function enableApp($appId);
|
||||||
|
|
|
@ -134,10 +134,11 @@ class ManagerTest extends TestCase {
|
||||||
try {
|
try {
|
||||||
$this->manager->enableApp('some_random_name_which_i_hope_is_not_an_app');
|
$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.');
|
$this->assertFalse(true, 'If this line is reached the expected exception is not thrown.');
|
||||||
} catch (\Exception $e) {
|
} catch (AppPathNotFoundException $e) {
|
||||||
// excpetion is expected
|
// Exception 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());
|
$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(
|
$this->assertEquals('no', $this->appConfig->getValue(
|
||||||
'some_random_name_which_i_hope_is_not_an_app', 'enabled', 'no'
|
'some_random_name_which_i_hope_is_not_an_app', 'enabled', 'no'
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in New Issue