From 69279247f407dd19507c3425d41a7a3931204384 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Tue, 17 Sep 2024 20:25:50 +0200 Subject: [PATCH] #49 add: catch general exceptions Signed-off-by: Patrizio Bekerle --- lib/Controller/NoteApiController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Controller/NoteApiController.php b/lib/Controller/NoteApiController.php index a086b21..ffd6528 100644 --- a/lib/Controller/NoteApiController.php +++ b/lib/Controller/NoteApiController.php @@ -20,6 +20,7 @@ use OCA\Files_Versions\Storage; use OCP\AppFramework\ApiController; use OCP\IRequest; +use OCP\Util; class NoteApiController extends ApiController { @@ -57,11 +58,11 @@ public function getAllVersions() { $source = $this->request->getParam('file_name', ''); $errorMessages = []; + $versionsResults = []; try { [$uid, $filename] = Storage::getUidAndFilename($source); $versions = Storage::getVersions($uid, $filename, $source); - $versionsResults = []; if (is_array($versions) && (count($versions) > 0)) { require_once __DIR__.'/../../3rdparty/finediff/finediff.php'; @@ -93,9 +94,9 @@ public function getAllVersions() } } catch (\OCP\Files\NotFoundException $exception) { // Requested file was not found, silently fail (for now) - $versionsResults = []; - $errorMessages[] = 'Requested file was not found!'; + } catch (Exception $exception) { + $errorMessages[] = 'An error happened: ' . $exception->getMessage(); } return [