Catch possible database exceptions when fetching document data

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2020-11-25 10:00:33 +01:00
Родитель 41931998c1
Коммит de706b4398
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4C614C6ED2CDE6DF
1 изменённых файлов: 13 добавлений и 7 удалений

Просмотреть файл

@ -32,6 +32,7 @@ use OCA\Activity\Data;
use OCA\Text\DocumentHasUnsavedChangesException;
use OCA\Text\DocumentSaveConflictException;
use OCA\Text\VersionMismatchException;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
@ -161,20 +162,25 @@ class ApiService {
return new DataResponse(['steps' => []]);
}
$result = [
'steps' => $this->documentService->getSteps($documentId, $version),
'sessions' => $this->sessionService->getActiveSessions($documentId),
'document' => $this->documentService->get($documentId)
];
$session = $this->sessionService->getSession($documentId, $sessionId, $sessionToken);
try {
$result = [
'steps' => $this->documentService->getSteps($documentId, $version),
'sessions' => $this->sessionService->getActiveSessions($documentId),
'document' => $this->documentService->get($documentId)
];
$session = $this->sessionService->getSession($documentId, $sessionId, $sessionToken);
$file = $this->documentService->getFileForSession($session, $token);
} catch (NotFoundException $e) {
$this->logger->logException($e, ['level' => ILogger::INFO]);
return new DataResponse([
'message' => 'File not found'
], 404);
} catch (DoesNotExistException $e) {
$this->logger->logException($e, ['level' => ILogger::INFO]);
return new DataResponse([
'message' => 'Document no longer exists'
], 404);
}
try {