diff options
author | Julien Veyssier <eneiluj@posteo.net> | 2021-12-28 16:18:35 +0300 |
---|---|---|
committer | Julien Veyssier <eneiluj@posteo.net> | 2022-01-03 12:27:38 +0300 |
commit | 29b7e0fdf39e461fc7e5e037e05a2fcb7db41a4f (patch) | |
tree | 22f0a8484bf475fab9693edff69ecd673736248a /lib/Controller | |
parent | cde5784141cd3ebb3fc31e7801727521c62df8bc (diff) |
stop returning null in getAttachmentDirectoryForFile, use exceptions instead
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/ImageController.php | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/Controller/ImageController.php b/lib/Controller/ImageController.php index c8a0e6178..675fcfe1f 100644 --- a/lib/Controller/ImageController.php +++ b/lib/Controller/ImageController.php @@ -98,9 +98,7 @@ class ImageController extends Controller { try { $insertResult = $this->imageService->insertImageFile($documentId, $imagePath, $userId); - return isset($insertResult['error']) - ? new DataResponse($insertResult, Http::STATUS_BAD_REQUEST) - : new DataResponse($insertResult); + return new DataResponse($insertResult); } catch (Exception $e) { $this->logger->error('File insertion error', ['exception' => $e]); return new DataResponse(['error' => 'File insertion error'], Http::STATUS_BAD_REQUEST); @@ -131,9 +129,7 @@ class ImageController extends Controller { $userId = $session->getUserId(); $downloadResult = $this->imageService->insertImageLink($documentId, $link, $userId); } - return isset($downloadResult['error']) - ? new DataResponse($downloadResult, Http::STATUS_BAD_REQUEST) - : new DataResponse($downloadResult); + return new DataResponse($downloadResult); } catch (Exception $e) { $this->logger->error('Link insertion error', ['exception' => $e]); return new DataResponse(['error' => 'Link insertion error'], Http::STATUS_BAD_REQUEST); @@ -170,11 +166,7 @@ class ImageController extends Controller { $userId = $session->getUserId(); $uploadResult = $this->imageService->uploadImage($documentId, $newFileName, $newFileContent, $userId); } - if (isset($uploadResult['error'])) { - return new DataResponse($uploadResult, Http::STATUS_BAD_REQUEST); - } else { - return new DataResponse($uploadResult); - } + return new DataResponse($uploadResult); } return new DataResponse(['error' => 'No uploaded file'], Http::STATUS_BAD_REQUEST); } catch (Exception $e) { |