diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-10-03 16:35:59 +0300 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-10-03 16:35:59 +0300 |
commit | b63d8b35e7ca8a0b98ed9a5f66771368800d09c5 (patch) | |
tree | d908133de7f2d15050e05ab70b43ce4b7d368575 /lib | |
parent | 8f2fab223fb2927cc6fbe8b74f868b0bf44a8b98 (diff) |
Throw proper NotFoundException if a file is not found by id
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Service/DocumentService.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php index bbfb2b199..605a404fc 100644 --- a/lib/Service/DocumentService.php +++ b/lib/Service/DocumentService.php @@ -307,8 +307,16 @@ class DocumentService { } } + /** + * @throws NotFoundException + */ public function getFileById($fileId): Node { - return $this->rootFolder->getUserFolder($this->userId)->getById($fileId)[0]; + $files = $this->rootFolder->getUserFolder($this->userId)->getById($fileId); + if (count($files) === 0) { + throw new NotFoundException(); + } + + return $files[0]; } public function getFileByPath($path): Node { |