Raise 404 error instead of 500 if permalink access is denied

This commit is contained in:
ArthurHoaro 2020-10-28 12:54:52 +01:00
parent 34c8f558e5
commit 156061d445
2 changed files with 3 additions and 3 deletions

View file

@ -106,7 +106,7 @@ public function findByHash(string $hash, string $privateKey = null): Bookmark
&& $first->isPrivate() && $first->isPrivate()
&& (empty($privateKey) || $privateKey !== $first->getAdditionalContentEntry('private_key')) && (empty($privateKey) || $privateKey !== $first->getAdditionalContentEntry('private_key'))
) { ) {
throw new Exception('Not authorized'); throw new BookmarkNotFoundException();
} }
return $first; return $first;

View file

@ -886,8 +886,8 @@ public function testFilterHashInValid()
*/ */
public function testFilterHashPrivateWhileLoggedOut() public function testFilterHashPrivateWhileLoggedOut()
{ {
$this->expectException(\Exception::class); $this->expectException(BookmarkNotFoundException::class);
$this->expectExceptionMessage('Not authorized'); $this->expectExceptionMessage('The link you are trying to reach does not exist or has been deleted');
$hash = smallHash('20141125_084734' . 6); $hash = smallHash('20141125_084734' . 6);