aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-10-22 08:20:04 +0200
committerprovokateurin <kate@provokateurin.de>2024-10-28 13:07:38 +0100
commit2ba4f6b2a020211a83993a9de40f3647e413f0c6 (patch)
tree99c28e58284f0f722a61d64d91a7540add80edba
parent0e4ab29304daf9113a19206a5e05be99725e1901 (diff)
downloadnextcloud-server-backport/48918/stable30.tar.gz
nextcloud-server-backport/48918/stable30.zip
fix(files_sharing): Cleanup error messagesbackport/48918/stable30
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php20
-rw-r--r--apps/files_sharing/tests/ApiTest.php2
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php2
3 files changed, 12 insertions, 12 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index dfbcc31ba81..616c175a9b4 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -158,7 +158,7 @@ class ShareAPIController extends OCSController {
if ($isOwnShare) {
$result['item_permissions'] = $node->getPermissions();
}
-
+
// If we're on the recipient side, the node permissions
// are bound to the share permissions. So we need to
// adjust the permissions to the share permissions if necessary.
@@ -645,7 +645,7 @@ class ShareAPIController extends OCSController {
$expireDateTime = $this->parseDate($expireDate);
$share->setExpirationDate($expireDateTime);
} catch (\Exception $e) {
- throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
+ throw new OCSNotFoundException($e->getMessage(), $e);
}
} else {
// Client sent empty string for expire date.
@@ -811,12 +811,11 @@ class ShareAPIController extends OCSController {
try {
$share = $this->shareManager->createShare($share);
} catch (GenericShareException $e) {
- $this->logger->error($e->getMessage(), ['exception' => $e]);
$code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), $code);
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
- throw new OCSForbiddenException($e->getMessage(), $e);
+ throw new OCSForbiddenException('Failed to create share.', $e);
}
$output = $this->formatShare($share);
@@ -1343,11 +1342,11 @@ class ShareAPIController extends OCSController {
$share->setExpirationDate(null);
} elseif ($expireDate !== null) {
try {
- $expireDate = $this->parseDate($expireDate);
+ $expireDateTime = $this->parseDate($expireDate);
+ $share->setExpirationDate($expireDateTime);
} catch (\Exception $e) {
throw new OCSBadRequestException($e->getMessage(), $e);
}
- $share->setExpirationDate($expireDate);
}
try {
@@ -1356,7 +1355,8 @@ class ShareAPIController extends OCSController {
$code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), (int)$code);
} catch (\Exception $e) {
- throw new OCSBadRequestException($e->getMessage(), $e);
+ $this->logger->error($e->getMessage(), ['exception' => $e]);
+ throw new OCSBadRequestException('Failed to update share.', $e);
}
return new DataResponse($this->formatShare($share));
@@ -1443,7 +1443,8 @@ class ShareAPIController extends OCSController {
$code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), (int)$code);
} catch (\Exception $e) {
- throw new OCSBadRequestException($e->getMessage(), $e);
+ $this->logger->error($e->getMessage(), ['exception' => $e]);
+ throw new OCSBadRequestException('Failed to accept share.', $e);
}
return new DataResponse();
@@ -2134,9 +2135,8 @@ class ShareAPIController extends OCSController {
$provider->sendMailNotification($share);
return new DataResponse();
- } catch(OCSBadRequestException $e) {
- throw $e;
} catch (Exception $e) {
+ $this->logger->error($e->getMessage(), ['exception' => $e]);
throw new OCSException($this->l->t('Error while sending mail notification'));
}
diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php
index 770ebd14f1e..9884465c973 100644
--- a/apps/files_sharing/tests/ApiTest.php
+++ b/apps/files_sharing/tests/ApiTest.php
@@ -1294,7 +1294,7 @@ class ApiTest extends TestCase {
$this->assertTrue($valid);
} catch (OCSNotFoundException $e) {
$this->assertFalse($valid);
- $this->assertEquals('Invalid date, date format must be YYYY-MM-DD', $e->getMessage());
+ $this->assertEquals('Invalid date. Format must be YYYY-MM-DD', $e->getMessage());
$ocs->cleanup();
return;
}
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index de820583d48..cdf38d66e0f 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -2212,7 +2212,7 @@ class ShareAPIControllerTest extends TestCase {
public function testCreateShareInvalidExpireDate() {
$this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
- $this->expectExceptionMessage('Invalid date, date format must be YYYY-MM-DD');
+ $this->expectExceptionMessage('Invalid date. Format must be YYYY-MM-DD');
$ocs = $this->mockFormatShare();