From 22e724e8292315f600b57a30716e26c1f1c04f66 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 30 Sep 2015 13:32:20 +0200 Subject: Only intercept exceptions of type "NotFoundException" instead of any Exception The sharing backend may throw another exception for example when the activity app encounters a problem. Previously this just triggered a 404 error page and the exception got not logged at all. With this change such exceptions get not intercepted and regularly handled as exceptions so that we have meaningful log data. Also the user will be shown a window informing him that an error happened. Helps to debug cases such as https://github.com/owncloud/core/issues/19465 --- apps/files_sharing/lib/controllers/sharecontroller.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'apps/files_sharing/lib/controllers') diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php index ecf3ee853ee..28feb3110b4 100644 --- a/apps/files_sharing/lib/controllers/sharecontroller.php +++ b/apps/files_sharing/lib/controllers/sharecontroller.php @@ -46,6 +46,7 @@ use OCA\Files_Sharing\Helper; use OCP\User; use OCP\Util; use OCA\Files_Sharing\Activity; +use \OCP\Files\NotFoundException; /** * Class ShareController @@ -148,6 +149,7 @@ class ShareController extends Controller { * @param string $token * @param string $path * @return TemplateResponse|RedirectResponse + * @throws NotFoundException */ public function showShare($token, $path = '') { \OC_User::setIncognitoMode(true); @@ -171,7 +173,7 @@ class ShareController extends Controller { $getPath = Filesystem::normalizePath($path); $originalSharePath .= $path; } else { - throw new OCP\Files\NotFoundException(); + throw new NotFoundException(); } $file = basename($originalSharePath); @@ -303,7 +305,7 @@ class ShareController extends Controller { /** * @param string $token * @return string Resolved file path of the token - * @throws \Exception In case share could not get properly resolved + * @throws NotFoundException In case share could not get properly resolved */ private function getPath($token) { $linkItem = Share::getShareByToken($token, false); @@ -312,7 +314,7 @@ class ShareController extends Controller { $rootLinkItem = Share::resolveReShare($linkItem); if (isset($rootLinkItem['uid_owner'])) { if(!$this->userManager->userExists($rootLinkItem['uid_owner'])) { - throw new \Exception('Owner of the share does not exist anymore'); + throw new NotFoundException('Owner of the share does not exist anymore'); } OC_Util::tearDownFS(); OC_Util::setupFS($rootLinkItem['uid_owner']); @@ -324,6 +326,6 @@ class ShareController extends Controller { } } - throw new \Exception('No file found belonging to file.'); + throw new NotFoundException('No file found belonging to file.'); } } -- cgit v1.2.3