Skip to content

Commit

Permalink
#49 add: catch general exceptions
Browse files Browse the repository at this point in the history
Signed-off-by: Patrizio Bekerle <[email protected]>
  • Loading branch information
pbek committed Sep 17, 2024
1 parent 41e44d5 commit 6927924
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/Controller/NoteApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use OCA\Files_Versions\Storage;
use OCP\AppFramework\ApiController;
use OCP\IRequest;
use OCP\Util;

class NoteApiController extends ApiController
{
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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 [
Expand Down

0 comments on commit 6927924

Please sign in to comment.