Log exceptions when creating share

Because the exceptions don't always contain a useful message for the UI,
but also because in some cases we need to find out what went wrong.

In some setups, a ShareNotFoundException might happen during creation
when we try to re-read the just written share. Usually related to Galera
Cluster where node syncing wait is not enabled.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
Vincent Petry 2021-03-15 12:00:41 +01:00
parent f82edda9c1
commit 6997344931
No known key found for this signature in database
GPG Key ID: E055D6A4D513575C
1 changed files with 2 additions and 0 deletions

View File

@ -631,9 +631,11 @@ class ShareAPIController extends OCSController {
try { try {
$share = $this->shareManager->createShare($share); $share = $this->shareManager->createShare($share);
} catch (GenericShareException $e) { } catch (GenericShareException $e) {
\OC::$server->getLogger()->logException($e);
$code = $e->getCode() === 0 ? 403 : $e->getCode(); $code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), $code); throw new OCSException($e->getHint(), $code);
} catch (\Exception $e) { } catch (\Exception $e) {
\OC::$server->getLogger()->logException($e);
throw new OCSForbiddenException($e->getMessage(), $e); throw new OCSForbiddenException($e->getMessage(), $e);
} }